anacronw / multer-s3

multer storage engine for amazon s3
MIT License
660 stars 190 forks source link

Overwriting #25

Closed arturojain closed 8 years ago

arturojain commented 8 years ago

There should be a way to disable file overwriting. Maybe something like:

var upload = multer({
  storage: s3({
    bucket: 'some-bucket',
    secretAccessKey: 'some secret',
    accessKeyId: 'some key',
    region: 'us-east-1',
    overwrite: false,
    key: function (req, file, cb) {
      cb(null, Date.now().toString())
    }
  })
})
anacronw commented 8 years ago

The crypto is there just to provide a unique signature for the file so no overwriting should be occurring unless you define your own function.

I'm not sure of your use case of course, but I would be wary of allowing your users to control that aspect of it by crafting their own filenames etc if its not sufficiently random.

arturojain commented 8 years ago

I mean, we could me it easier to overcome this common issue.

anacronw commented 8 years ago

You can of course define your own key for it to be sufficiently random. You'll have to turn on versioning on the bucket yourself if you want that feature.