我已经尝试 multer-s3 好几个小时了,但我无法创建缩略图。谁能告诉我如何运行它?
以下是我的代码:
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!')
})
原始图像已成功上传,但调整大小的图像未成功。谁能指导我?
谢谢