angular-upload icon indicating copy to clipboard operation
angular-upload copied to clipboard

Binary file not uploading properly

Open simonh1000 opened this issue 11 years ago • 1 comments

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?

simonh1000 avatar Dec 28 '14 19:12 simonh1000

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

leon avatar Dec 29 '14 10:12 leon