如何发送文件,以便服务器使用fs.createwriteStream()读取;
var http = require('http');
var fs = require('fs');
http.createServer(function(req, res) {
// This opens up the writeable stream to `output`
var writeStream = fs.createWriteStream('./output');
// This pipes the POST data to the file
req.pipe(writeStream);
req.on('end', function () {
res.end('ok upload file');
});
// This is here incase any errors occur
writeStream.on('error', function (err) {
console.log(err);
});
}).listen(8080);
我在控制台linux中使用此命令:curl——上传文件hello.txt 127.0.0.1:3000,工作正常,但我不知道如何用url 发送文件
有人知道吗?
curl-i-F name=test-F filedata=@localfile.jpg 127.0.0.1:3000