Sails.js download file - Unable to get file on req.file ()

I am just starting out with Sailsjs and I tried to make a simple file upload. In the sails I like

uploadFile: (req, res) => {
		req.file('avatar').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
			});
		});
	}
Run code

And at the postman I liked it upload file via postman

The fact is that after downloading the file through the postman, I do not receive the file in the req.file () file. But while I was console.log (req), I really saw the binary file (something like this). I just can't understand what happened.

+4
source share

Source: https://habr.com/ru/post/1675870/


All Articles