【发布时间】:2016-01-08 10:43:14
【问题描述】:
我想上传大文件。 (15 GB) 但卷曲结果:管道破裂?我究竟做错了什么??
app.js
var http = require('http');
var fs = require('fs');
http.createServer(function(req, res){
var newFile = fs.createWriteStream('new_file.mkv');
var method = req.method;
var newSize = 0;
if(method == 'PUT'){
req.pipe(newFile);
req.on('data', function(chunk){
newSize += chunk.length;
console.log(newSize);
});
}
}).listen(8000, function(){
console.log('Listening..');
});
控制台命令:
curl --upload-file read.mkv http://127.0.0.1:8000
结果:
curl: (55) Send failure: Broken pipe
我做错了什么?
【问题讨论】:
-
灵魂?我不明白。
-
你可以试试这个命令吗:
curl -iv -F name=filename -F filedata=@read.mkv http://127.0.0.1:8000。我没有测试,请确保没有语法错误或其他问题 -
如果你仍然有问题,你的文件上传你可以试试这个库:github.com/felixge/node-formidable
-
别跑。请帮忙。
标签: javascript node.js curl upload pipe