This is error which am getting while post data and file. I have followed \'academind\' tutorial for building Restful API services, also i have been searching answer for this
I am doing the same course and I too had the same problem (i also use windows machine). The following worked for me:
const hash = require('random-hash'); // you have to install this package:
const fileStorage = multer.diskStorage({
destination: (req, file, callback) => { //this is storing the file in the images folder
callback(null, path.join(__dirname, '/Images'));
},
filename: (req, file, callback) => { //this is just setting a unique filename
let temp = file.originalname.split('.');
const filename = temp[0] + '-' + hash.generateHash({length: 5}) + '.' + temp[1]
callback(null, filename);
}
});
This creates a unique hash for the filenames as well