Not sure if you are still looking for the answer to this question, but I had the same problem. I decided to expand the multer-s3 package.
I opened a request to transfer to the original repository , but for now you can use my plug .
Here is an example using the extended version:
var upload = multer({ storage: multerS3({ s3: s3, bucket: 'some-bucket', shouldTransform: function (req, file, cb) { cb(null, /^image/i.test(file.mimetype)) }, transforms: [{ id: 'original', key: function (req, file, cb) { cb(null, 'image-original.jpg') }, transform: function (req, file, cb) { cb(null, sharp().jpg()) } }, { id: 'thumbnail', key: function (req, file, cb) { cb(null, 'image-thumbnail.jpg') }, transform: function (req, file, cb) { cb(null, sharp().resize(100, 100).jpg()) } }] }) })
EDIT: My fork is now also available through npm under the name multer-s3-transform .
Itsgreg
source share