title: How to post large amount of json data (not file) in nodejs/express
body: <p>So I am doing an ajax(jquery) post that uploads quite a big amount of json data. When posting a large data, the data is generally broken into chunks. So we have to listen for post data requests and construct a full buffer of the upload data. Something like this:</p>
  
  <pre><code>    req.on('data', function(chunk) {
          console.log("upload on data "+ chunk.length);
          chunks.push(chunk);
          total+= chunk.length;
      });
      req.on('error', function(e) {
              console.log('Got Error ' + e.message);
      });
      req.on('end', function() {
          var buf = new Buffer(total)
              cur = 0;
          for (var i = 0, l = chunks.length; i &lt; l; i++) {
              chunks[i].copy(buf, cur, 0);
              cur += chunks[i].length;
          }
  
          var level = 1;
          var path = "level"+level+".json";
          writeToFile(buf,path);
          res.send("Update successfull as level "+level);
      });
  </code></pre>
  
  <p>This seems to be working if I am uploading a file with form:</p>
  
  <pre><code>function display_form(req, res) {
      res.sendHeader(200, {"Content-Type": "text/html"});
      res.write(
          '&lt;form action="/upload" method="post" enctype="multipart/form-data"&gt;'+
          '&lt;input type="file" name="upload-file"&gt;'+
          '&lt;input type="submit" value="Upload"&gt;'+
          '&lt;/form&gt;'
      );
      res.close();
  }
  </code></pre>
  
  <p>But I need to upload json data (which is dynamic).  I am doing this in this way:</p>
  
  <pre><code>           $.ajax({
                  type: "POST",
                  url: "/upload",
                  data: {"data": JSON.stringify(gamePack)},
                  success: cb,
              });
  </code></pre>
  
  <p>Then there seems to be no callback to req 'data' or 'end'. So how are uploading files different from posting data? </p>