File uploads to S3 via multer-s3 in my express app is ridiculously slow (200kb takes 10 seconds, latency scales in relation to file size). Problem is multer-s3 but can someone tell how to further debug what's happening within the library? Passing onFileUploadStart etc to multer is no longer supported. I have no idea how to peak inside what multer-s3 is doing and in which stages is the latency caused.
Problem is not AWS S3 as uploading from CLI is super-fast, neither is it multer as uploading to local disk is also fast. Any direct S3 javascript operations also work as fast as intended.
Tried turning off multer's content auto type feature but it didn't do much.
var upload = multer({
storage: multerS3({
s3: s3,
bucket: bucketName,
acl: 'public-read',
contentType: multerS3.AUTO_CONTENT_TYPE,
metadata: function (req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key: function (req, file, cb) {
cb(null, Date.now().toString() + "-" + file.originalname);
}
},)
})
router.post('/', upload.array('files'), function(req, res, next) {
console.log('Successfully uploaded ' + req.files.length + ' files!');
});
Want to have sub-second latency as I do with direct AWS CLI upload or using multer to store to local disk, takes 10 seconds to minute or more on sub-MB files.