You can try busboy https://github.com/mscdex/busboy :
this.route('/upload', { where: 'server', method: 'POST', name:'upload', onBeforeAction: (function (req, res, next) { //busboy code here var busboy = new Busboy({ headers: req.headers }); busboy.on('file', function(fieldname, file, filename, encoding, mimetype) { console.log('File [' + fieldname + ']: filename: ' + filename + ', encoding: ' + encoding + ', mimetype: ' + mimetype); file.on('data', function(data) { console.log('File [' + fieldname + '] got ' + data.length + ' bytes'); }); file.on('end', function() { console.log('File [' + fieldname + '] Finished'); }); }); busboy.on('field', function(fieldname, encoding, mimetype) { console.log('Field [' + fieldname + ']: value: ' + inspect(val)); }); busboy.on('finish', function() { console.log('Done parsing form!'); res.writeHead(303, { Connection: 'close', Location: '/' }); res.end(); next(); }); req.pipe(busboy); });
you can use file.pipe(fs.createWriteStream(saveTo));
and saveTo is the path where you download, for example: C:/media/ , and try to create an ang Path for the link example: localhost:80/media/image-here.png use the method to store this link in your database, you can Use APACHE to host files.
source share