I just begin with Sailsjs and I tried to make a simple file upload. In sails I do like
uploadFile: (req, res) => {
req.file('test').upload({
dirname: '../../assets/uploads'
}, function (err, uploadedFiles){
if (err) return res.serverError(err);
return res.json({
message: uploadedFiles.length + ' file(s) uploaded successfully!',
files: uploadedFiles
});
});
}
And in the postman I did like this Upload file via postman
The thing is after I upload file via postman I get no file in req.file(). But while I console.log(req) I actually did see the file's binary(some sorts like that). I just cannot figure out what happened.
via 蔡一鸣
No comments:
Post a Comment