node.js - uploaded file differ with the original -


i'm trying upload file node using simple code:

updatecontroller.prototype.uploadupdatefile = function(req, res) {     var w = fs.createwritestream(settings.uploadfolder + settings.updatefile);     req.pipe(w);     w.on('finish', function()     {         res.send(json.stringify({             status:0,             filename:settings.uploadfolder + settings.updatefile         }));     }, function()     {         res.send(json.stringify({             status:1,             message:"error during file upload, operation failed"         }));     }); } 

the file correctly uploaded changes between original because header (------webkitform ... /octet-stream....) , footer (..------webkitformboundary9gozjmubs9givcuq--..) added content.

how file content ?

you have @ headers of client request understand how client decided send file (how file encoded)

you end using busboy or package depends on : https://www.npmjs.com/package/busboy

such package "decode" data sent browser.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -