Q:

NodeJS stuck in uploading image

I have a piece of Node code to upload images. Images are of size of 10~200K. As you can see thy are not big at all.The problem is that it seems that Node keeps busy for a long time (can be 10 minutes) on uploading and it won't response to new requests. The code is part of JSON API consumed by an Android app.
var fs = require('fs');

exports.upload = function(req, res){
  ....
  var rawBody = new Buffer('');
  req.on('data', function(chunk){
                rawBody = Buffer.concat([rawBody, chunk]);
  });
  req.on('end', function(){
                winston.info('on end of uploading moment');
                fs.writeFile(filepath, rawBody, 'binary', function(err){
                    if(err) winston.error(err);
                    else{

                        db.updatesomething();
                    }
                });
            });

A:

The request never returns anything to the browser, which is why it's hanging, it's waiting for a response
var fs = require('fs');

exports.upload = function(req, res){

    var rawBody = new Buffer('');
    req.on('data', function(chunk){
          rawBody = Buffer.concat([rawBody, chunk]);
    });
    req.on('end', function(){
        winston.info('on end of uploading moment');
        fs.writeFile(filepath, rawBody, 'binary', function(err){
            if(err) {
                winston.error(err);
                res.end('error');
            } else {
                db.updatesomething();
                res.end('success'); // send a response back
            }
        });
    });
});

