Upload HUGE file > 2GB to nodejs (n Firefox)

I’ve made my example as basic possible. I try to upload a huge file, more than 2 GB, to my server but I receive an error only in Firefox. In Chrome seems to work allright. It says something like “Error: Connection broken”. Could someone explain me why and what could I do about it?

var http       = require("http");
var url        = require("url");

http.createServer(function (request, response) {
    switch(url.parse(request.url).pathname) {
        case "/":
            displayForm(request, response);
        case "/upload":
            response.writeHeader(200, {"Content-Type":"text/html"});
                '<h1>File Uploaded!</h1>'

var displayForm = function(request, response) {
    response.writeHeader(200, {"Content-Type":"text/html"});
        '<form action="/upload" method="post" enctype="multipart/form-data">' +
            '<input type="file" name="uploadFile">' +
            '<input type="submit" value="Upload!">' +

EDIT: I just realized it only happens in Firefox, not in Chrome!

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

For such large files I recommend you to read your file with FileReader, chunk it on small binary pieces with Blob or Blobbuilder and transfer (by Socket.io) the file chunk by chunk with progress bar, concatenating the chunks on the server. When last chunk is sent – you got full file on your backend.

You can also save current chunk number in cookie/LocalStorage in case of connection breaks to continue transfer.

P.S. For ancient IE’s and other shit there is flash plugin for using Blobs, google it.

P.S.S Max file size by POST requests for different browsers: http://motobit.com/help/scptutl/pa98.htm

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply