Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Javascript upload chunk sizes change by browser?

I am uploading files by javascript code to server. I noticed that different browsers are sending bytes of different sizes. As you can see in the following pictures, Internet Explorer is sending small bytes but Chrome and Firefox send bigger bytes.

  1. I am uploading files with XMLHttpRequest. Can I set standard upload bytes for all browsers? Because different size flow is giving errors on some browsers. Http error is 404.13.
  2. I configured web.config file as <requestLimits maxAllowedContentLength="1073741824">(1GB) but when I upload a big file(500 Mb) with Firefox and Chrome, the server is giving system.OutOfMemoryException. Internet Explorer is working fine.

Firefox

enter image description here

Internet Explorer

enter image description here

Chrome

enter image description here

like image 677
barteloma Avatar asked Nov 12 '22 20:11

barteloma


1 Answers

I don't know why it's different, but you can alter your behavior based on the browser (as opposed to standardizing as you asked in the question).

Refer to the code in the moo uploader as an example.

From: https://github.com/juanparati/MooUpload/blob/master/Source/MooUpload.js

    // Get slice method
    if (file.mozSlice)          // Mozilla based
      chunk = file.mozSlice(start, total)
    else if (file.webkitSlice)  // Chrome, Safari, Konqueror and webkit based
      chunk = file.webkitSlice(start, total);
    else                        // Opera and other standards browsers
      chunk = file.slice(start, total)
like image 108
Jamey Avatar answered Nov 15 '22 02:11

Jamey