When the following POST API is called, it must save the file to the file system. However, the file is not saved. I see the file in the console, but I can not save or write it. I have the following code:
router.post('/notes', function(req, res, next) { var gfsstream, startFileWrite, endFileWriteTime; var busboy = new Busboy({ headers: req.headers }); busboy.on('file', function(fieldname, file, filename, encoding, mimetype) { startFileWrite = new Date().getTime(); console.log('File [' + fieldname + ']: filename: ' + filename); gfsstream = gfs.createWriteStream('/uploads'); file.on('data', function(data) { gfsstream.write(data); }); file.on('end', function() { gfsstream.end(); req.pipe(gfsstream); }); gfsstream.on('close', function (file) {
req.pipe(gfsstream) may be the problem here, but I'm not sure what is stopping the file from being saved.
DemCodeLines
source share