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
Post a Comment