我无法使用 multer-s3 上传大文件。它也没有给我任何错误。
I am not able to upload large files using multer-s3. It is not giving me any error as well.
我无法使用 multer-s3 上传大文件。它也没有给我任何错误。它只是不上传文件,甚至不进入回调并超时。有什么方法可以处理将大文件上传到 s3 Bucket 吗?
我是这样使用的:
var uploadSingle = upload.single('uploadFile');
router.post('/uploadVideo',function(req,res,next){
uploadSingle(req,res,function(err){
// doesn't come here if the file is large
if(err){
//Error Response , Error while uploading Module PDF;
}
else{
//handling file upload
// success response
}
});
}
我遇到了同样的问题,在研究 this page 之后,我发现我需要添加 contentLength
作为参数之一。它的值是以字节为单位的长度。
const s3 = new AWS.S3({
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
});
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'myBucket',
contentType: multerS3.AUTO_CONTENT_TYPE,
contentLength: 500000000,
metadata: function (req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key: function (req, file, cb) {
cb(null, file.originalname);
}
})
});
router.post('/uploadToS3', upload.array('photos', 30), function(req, res, next) {
res.send({"message": 'Successfully uploaded ' + req.files.length + ' files!'});
})
我无法使用 multer-s3 上传大文件。它也没有给我任何错误。它只是不上传文件,甚至不进入回调并超时。有什么方法可以处理将大文件上传到 s3 Bucket 吗?
我是这样使用的:
var uploadSingle = upload.single('uploadFile');
router.post('/uploadVideo',function(req,res,next){
uploadSingle(req,res,function(err){
// doesn't come here if the file is large
if(err){
//Error Response , Error while uploading Module PDF;
}
else{
//handling file upload
// success response
}
});
}
我遇到了同样的问题,在研究 this page 之后,我发现我需要添加 contentLength
作为参数之一。它的值是以字节为单位的长度。
const s3 = new AWS.S3({
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
});
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'myBucket',
contentType: multerS3.AUTO_CONTENT_TYPE,
contentLength: 500000000,
metadata: function (req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key: function (req, file, cb) {
cb(null, file.originalname);
}
})
});
router.post('/uploadToS3', upload.array('photos', 30), function(req, res, next) {
res.send({"message": 'Successfully uploaded ' + req.files.length + ' files!'});
})