简体   繁体   中英

How to provide public read access to a file in s3fs in node.js

I want to provide public read access to file uploaded in folder on s3 amazon server.My code sample is

    var s3Options = {
                  accessKeyId: config.bucket_access_key,
                  secretAccessKey: config.bucket_secret_access_key
         };

    var fsImpl = new S3FS(config.bucket_name, s3Options);
    fsImpl.writeFile(fileName, stream).then(function (err,data) {
      //code
    });

It can be done by adding 'ACL' key -

 fsImpl.writeFile(fileName, stream,{ACL: 'public-read'}).then(function (err,data) {  
     // code
 })

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM