问题描述
这是我的模特
const CheckIn = function (file) {
this.type = file.type;
this.name = file.name;
this.data = file.data;
};
CheckIn.create = (newCheckIn,result) => {
sql.query(`INSERT INTO files_checkin (type,name,data) VALUES (?,?,?)`,[newCheckIn.type,newCheckIn.name,newCheckIn.data],(err,res) => {
if (err) {
console.log("error: ",err);
result(err,null);
return;
}
console.log("created image: ",{
nr: res.insertId,...newCheckIn
});
result(null,...newCheckIn
});
});
};
还有我的控制器的一部分
exports.create = (req,res) => {
console.log("body " + JSON.stringify(req.body));
if (!req.body) {
res.status(400).send({
message: "Content can not be empty!"
});
}
const checkin = new CheckIn({
type: req.file.mimetype,name: req.file.originalname,data: req.file.buffer
});
CheckIn.create(checkin,data) => {
if (err)
res.status(500).send({
message: err.message || "Some error occurred while creating the Alias."
});
else res.send(data);
});
};
一切正常,直到我想上传例如5mb大小的图像为止。 然后我收到了loooooong blob,我的终端崩溃了。 看起来像矩阵。
我应该如何上传大块?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)