//limit 最大限制

app.use("/record/:where/:id", bodyParser.raw({"limit":"50mb"}), function (req, res, next) {
console.log("YES====");

let where = req.params.where;
let id = req.params.id;
//console.log("id==="+id);
let file = "";

let dirpath = "/Users/tmp/";

let dirname = "remote"+id+".webm";

let dirname2 = "local"+id+".webm";
//判断文件夹是否存在
if (!fs.existsSync("/Users/tmp")) {
fs.mkdirSync("/Users/tmp");
}

if (where === "remote") {
file = dirpath+dirname;
} else if (where === "local") {
file = dirpath + dirname2;
}else{
return;
}
fs.writeFile(file, req.body, "binary", function (err) {
if (err) {
console.log("localBlobs fail", err);
} else {
console.log("localBlobs success");
}
});

 

});

posted on 2017-08-15 17:01  大峰1992  阅读(446)  评论(0编辑  收藏  举报