我有以下脚本应该接收上传的图像/视频并将其保存到磁盘。该脚本适用于高达1.5Mb的图像,超过该大小,文件上载显示0个字节。我节省了很多可用空间,所以免费空间不是问题。
我正在使用SoapUI进行请求,媒体类型为image / jpeg。
http://127.0.0.1:8080/api/uploadfile/Test/cake.jpg
为什么较小的文件会起作用,但较大的文件会失败?
var restify = require('restify');
var fs = require('fs');
function uploadFile(req, res, next) {
var path = req.params.devicename;
var filename = req.params.filename;
console.log("Upload file");
var writeStream = fs.createWriteStream(path + "/" + filename);
var r = req.pipe(writeStream);
r.on("finish", function () {
res.send(200,"Upload complete");
});
next();
}
var server = restify.createServer();
server.post('/api/uploadfile/:devicename/:filename', uploadFile);
server.listen(8080, function() {
console.log('%s listening at %s', server.name, server.url);
});