Multer-s3-transform在Express JS路由中使用Sharp中间件,可以正确上传,但从不调用next

Multer-s3-transform在Express JS路由中使用Sharp中间件,可以正确上传,但从不调用next,express,amazon-s3,multer-s3,Express,Amazon S3,Multer S3,我正在使用multer-s3-transform来调整我上传到s3之前的图像大小。使用夏普调整大小。转换工作正常,图像被调整大小并上传到S3 bucket,我可以看到bucket中的文件。然而,uploadToS3.single('profilePic')中间件永远不会继续到下一个路由,即结束路由 我做错了什么 exports.uploadToS3 = multer({ storage: multerS3({ s3: s3, bucket: S3_BUCK

我正在使用multer-s3-transform来调整我上传到s3之前的图像大小。使用夏普调整大小。转换工作正常,图像被调整大小并上传到S3 bucket,我可以看到bucket中的文件。然而,uploadToS3.single('profilePic')中间件永远不会继续到下一个路由,即结束路由

我做错了什么

exports.uploadToS3 = multer({
    storage: multerS3({
        s3: s3,
        bucket: S3_BUCKET,
        acl: 'public-read',
        contentType: multerS3.AUTO_CONTENT_TYPE,
        fileFilter: allowOnlyImages,
        limits: {
            fileSize: 1024 * 250 // We are allowing only 250K
        },
        shouldTransform: (req, file, cb) => {
            // Is this an image file type?
            cb(null, /^image/i.test(file.mimetype));
        },
        transforms: [{
            id: 'thumbnail',
            key: (req, file, cb) => {
                const fn = `${S3_PROFILE_PICS}/${req.body.handle}/${createFilename(req, file)}`;
                //console.log('transforms key fn: ', fn);
                cb(null, fn);
            },
            transform: (req, file, cb) => {
                //console.log('transform: ', file.originalname);
                // Perform desired transformations
                const width = parseInt(PROFILE_PIC_W);
                const height = parseInt(PROFILE_PIC_H);
                cb(null, sharp()
                    .resize(width, height)
                    .toFormat('jpeg')
                );
            }
        }]
    })
});
路线

router.post('/register', uploadToS3.single('profilePic'), async (req, res) => {
    ...
    ...
});

这与变换和/或锐化有关。如果我删除了Sharp变换,只需将传入图像上传到S3,一切正常。

请尝试以下操作以查看其是否正常工作:

router.post('/register', uploadToS3.single('profilePic'), async (req, res, next) => {
    ...
    ...
});