i'm uploading media files to s3 with express and multer-s3. it's working fine if i upload files less than 10 mb.
if i upload larger than 7mb( i tested for. if i upload around 30mb it'll fail), it gives error.cannot determine length of string
I'm uploading .mp4
file
Error Message
Exception has occurred: Error
Error: Cannot determine length of [object Object]
at byteLength (projectpath/node_modules/aws-sdk/lib/util.js:200:26)
at ManagedUpload.adjustTotalBytes (projectpath/node_modules/aws-sdk/lib/s3/managed_upload.js:299:25)
at ManagedUpload.configure (projectpath/node_modules/aws-sdk/lib/s3/managed_upload.js:122:10)
at new ManagedUpload (projectpath/node_modules/aws-sdk/lib/s3/managed_upload.js:93:10)
at features.constructor.upload (projectpath/node_modules/aws-sdk/lib/services/s3.js:1087:20)
at S3Storage.<anonymous> (projectpath/node_modules/multer-s3/index.js:182:26)
at projectpath/node_modules/multer-s3/index.js:68:10
at FileStream.<anonymous> (projectpath/node_modules/multer-s3/index.js:47:5)
at Object.onceWrapper (events.js:286:20)
at FileStream.emit (events.js:198:13)
at FileStream.EventEmitter.emit (domain.js:448:20)
at FileStream.Readable.read (_stream_readable.js:491:10)
at flow (_stream_readable.js:957:34)
at resume_ (_stream_readable.js:938:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
my code
Body parser config
app.use(bodyparser.urlencoded({ extended: true, limit: '1024mb' }));
app.use(bodyparser.json({}));
file route
router.route('/faqvideoupload')
.post(faqFileUpload.array('files', 1), uploadFileHandler)
faqFileUpload
module.exports.faqFileUpload = multer({
storage: multerS3({
s3: s3,
acl: 'public-read',
bucket: process.env.BUCKET_NAME,
contentDisposition: 'inline',
// contentLength: 1 * 1024 * 1024 * 1024,
contentType: multerS3.AUTO_CONTENT_TYPE,
metadata: function (req, file, cb) {
cb(null, { fieldName: file.fieldname, });
},
key: function (req, file, cb) {
// console.log(file, 23244324)
cb(null, `faqs/videos/filename}`)
}
})
})
uploadFileHandler
async function uploadFileHandler(req, res){
try {
let files = req.files.map((img)=> {
return {
key : img.key, location : img.location, type: img.mimetype
}
})
return res.json({
success : true,
files
})
} catch (error) {
return res.json({
success: false,
message: error.message
})
}
}
do i need to change any setting in s3 bucket itself?
i also read that i have to contentLength but this also not work.
i'm using t2.micro ec2 with eb