我在带有多方包的 node.js 中有文件上传系统
var gm = require('gm').subClass({imageMagick: true});
var multiparty = require('multiparty');
var form = new multiparty.Form();
var s3 = sails.config.aws.main();
var options = {
partSize: 5242880, queueSize: 1
}
form.parse(req, function(err, fields, files) {
gm(files.fileToUpload[0].path)
.resize(200,200,'^')
.stream(function (err,buffer) {
s3.upload({
Bucket:'mybucket',
Body:buffer,
Key:'artwork-croppedimages/test.jpg'
},options,function(err, data) {
console.log("upload error",err);
console.log("data",data);
});
})
});
它工作正常,但是当上传较大的文件通常大于 20 MB 时,我收到了这个错误
Error: Request aborted
at IncomingMessage.onReqAborted (/var/www/node/cushbuart/node_modules/multiparty/index.js:183:17)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:188:7)
at abortIncoming (_http_server.js:381:9)
at socketOnClose (_http_server.js:375:3)
at emitOne (events.js:101:20)
at Socket.emit (events.js:191:7)
at TCP._handle.close [as _onclose] (net.js:511:12)
我知道它通过增加超时来解决,但我不知道如何在sails.js 框架中