angular-upload
angular-upload copied to clipboard
Binary file not uploading properly
I'm using this jade on the client side
div(
class="btn btn-primary btn-upload"
upload-button
url="/api/gps"
method="POST"
required="true"
on-success="onSuccess(response)"
) Fileupload
And receive in nodejs with
exports.receive = function(req, res) {
var fitFileBuffer = new Buffer('');
req.on('data', function(chunk) {
fitFileBuffer = Buffer.concat([fitFileBuffer, chunk]);
});
req.on('end', function() {
fs.writeFileSync(
"server/api/gps/today2.fit",
fitFileBuffer);
When I upload today.fit (from a GPS) and compare with today2.fit that is saved, then it is clearly not the same final that is saved. What am I doing wrong?
I'm not a node developer, but I got my example working properly. There I just move the uploaded file instead of creating a buffer.
https://github.com/leon/angular-upload/blob/master/example/server.js#L33