I have an Express NodeJS server. I would like to upload very large files (more than 10Gb of size). I tried modules multer
and formidable
for this purpose.
My problem is that I am not able to receive more than 1Gb in the server. In the browser I get ERR_CONNECTION_RESET
. No error thrown by the server code.
My code with formidable
:
var formidable = require("formidable");
form = new formidable.IncomingForm();
form.uploadDir = "./files/";
form.parse(req, function(err, fields, files) {
console.log("received upload");
});
My code with multer
:
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "./files")
}
});
var upload = multer({storage: storage}).array("file",2);
/** ------ **/
upload(req, res, function (err) {
if (err) {
console.log("error");
} else { //success!
console.log("received upload");
}
});
Do you have any idea what is going on?
No need of using multer. try with this code.
var formidable = require("formidable");
var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files) {
});
form.on('end', function(fields, files, data) {
var temp_path = this.openedFiles[0].path;
var file_name = openedFiles[0].name;
var new_location = 'public/images/';
fs.move(temp_path, new_location + file_name, function(err) {
if ( err ) console.log(err);
else
console.log('upload-photo success');
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.