我有两个服务器。 server1将接收来自用户的上传请求,并将请求通过管道传送到server2以将文件上传到server2。这是我的server1代码
upload: function (req, res) {
console.log(req.headers);
console.log(req.body);
req.pipe(request.post('http://localhost:1337/file/upload')).pipe(res);
}
这是server2的代码:
upload: function (req, res) {
console.log(req.allParams());
console.log(req.file());
console.log(req.headers);
if (req.file("mot")) {
req.file('mot').upload({
dirname: require('path').resolve(sails.config.appPath, 'data')
}, function (err, data) {
if (err) {
console.log(err);
return res.json({
failed: true
});
} else {
console.log("file uploaded");
return res.ok();
}
}
)
}else{
}
}
在使用邮递员将上传请求直接发送到server2时起作用。但是当我向server1发送请求时,在server2上收到此错误:
{ Error: ETIMEOUT: An Upstream (`mot`) timed out waiting for file(s). No files were sent after waiting 10000ms.
at Timeout.<anonymous> (/media/thanhtv/Data/bitbucket/nodejs/test/node_modules/skipper/standalone/Upstream/Upstream.js:62:15)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
code: 'ETIMEOUT',
message:
'ETIMEOUT: An Upstream (`mot`) timed out waiting for file(s). No files were sent after waiting 10000ms.' }
请帮帮我。我在用帆。