I have been trying multer-s3 for many hours, But i'm failing in creating thumbnails. Can anyone please tell me how to run it?
Following is my code:
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'test',
// shouldTransform: function (req, file, cb) {
// cb(null, /^image/i.test(file.mimetype))
// },
acl: 'public-read',
contentType: multerS3.AUTO_CONTENT_TYPE,
shouldTransform : function (req, file, cb) {
console.log('in should transform ', file)
cb(null, /^image/i.test(file.mimetype))
},
transforms: [{
id: 'original',
key: function (req, file, cb) {
console.log('original')
cb(null, "original")
},
transform: function (req, file, cb) {
console.log('original1')
cb(null, sharp().jpg())
}
}, {
id: 'thumbnail',
key: function (req, file, cb) {
console.log('thumbnail')
cb(null, "thumbnail")
},
transform: function (req, file, cb) {
console.log('thumbnail1')
cb(null, file.resize(100, 100).jpg())
}
}]
})
})
app.post('/upload', upload.single('image'), extendTimeout, function(req, res, next) {
console.log('filessss ', req.file )
res.send('Successfully uploaded ' + req.file + ' files!')
})
Original image is uploaded successfully but resized image is not. Can anyone please guide me?
Thanks