From 986f9069cf53f7162262136286f9d6e10fd199d2 Mon Sep 17 00:00:00 2001 From: Nj Subedi Date: Tue, 20 Jul 2021 18:22:40 +0545 Subject: [PATCH] Support publicly readable file Add an optional boolean parameter named `makePublic` to the `put()` method. If `makePublic` is public, sets `ACL: 'public-read'` on the params, otherwise sets it to 'private', which is the default behavior. This change is backward compatible. --- packages/flydrive-s3/src/AmazonWebServicesS3Storage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flydrive-s3/src/AmazonWebServicesS3Storage.ts b/packages/flydrive-s3/src/AmazonWebServicesS3Storage.ts index 0e6e0f4..b3a7175 100644 --- a/packages/flydrive-s3/src/AmazonWebServicesS3Storage.ts +++ b/packages/flydrive-s3/src/AmazonWebServicesS3Storage.ts @@ -215,8 +215,8 @@ export class AmazonWebServicesS3Storage extends Storage { * Creates a new file. * This method will create missing directories on the fly. */ - public async put(location: string, content: Buffer | NodeJS.ReadableStream | string): Promise { - const params = { Key: location, Body: content, Bucket: this.$bucket }; + public async put(location: string, content: Buffer | NodeJS.ReadableStream | string, makePublic: boolean = false): Promise { + const params = { Key: location, Body: content, Bucket: this.$bucket, ACL: makePublic ? 'public-read' : 'private' }; try { const result = await this.$driver.upload(params).promise(); return { raw: result };