adamhenson / s3-image-uploader

A Node.js module for resizing, and uploading files to Amazon S3 with capability to track progress using websockets.
Other
44 stars 5 forks source link

Options to set the headers like cache expiration while uploading #1

Closed manikmi closed 8 years ago

manikmi commented 8 years ago

Hi Adam, Thanks for the nice package. Can we have some option like to set the header for the file uploaded? I see there is something like that in s3 package, which you are using internally. I want to set the cache expiration for my file uploaded to S3.

Thanks, Manik Mittal

adamhenson commented 8 years ago

@manikmi - Thanks for your feedback. I've added this feature.

You can now set any available params to the S3 object. I believe you were referring to the "CacheControl" options, so an example might look like:

s3Params : { 'CacheControl' : 'max-age=3600'}

So if you look at the example here https://github.com/adamhenson/example-s3-image-uploader/blob/master/server.js - the options would look similar to the below:

  uploader.upload({
    fileId : size + '_' + options.imgId,
    bucket : 'hensonism-test',
    source : options.imgPath,
    maxFileSize : 1,
    name : size + '_' + options.imgName,
    s3Params : { 'CacheControl' : 'max-age=3600'}
  },

I was able to use similar code and confirmed it updated in AWS (see screenshot below).

screen shot 2015-12-05 at 8 43 07 am

I've committed the update and pushed to NPM.