Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Big size file download

On my web page I have the following JS code to download file from server on user click:

var oReq = new XMLHttpRequest();
oReq.open("POST", otherUrl, true);
oReq.responseType = "arraybuffer";

oReq.onload = function(oEvent) {
    var blob = new Blob([oReq.response], 
                        {type: oReq.getResponseHeader('Content-Type')});
    var objectURL = URL.createObjectURL(blob);
    downloadLink.href = objectURL;
    downloadLink.click();
};
oReq.onprogress = function(oEvent) {
    var percentage = Math.round(oEvent.loaded/oEvent.total*100);
    
    downloadProgressDiv.innerHTML = "Progress: " + percentage + " % (" + oEvent.loaded 
                                    + " from " + oEvent.total + " )";
};
oReq.send(this.path);

It works for files below 1GB size. The issue I came across happens when file size I'm trying to download is about 3GB. In this case onprogress method works as with other files, onload method is invoked once download is completed, but oReq.response=null. Also I'm able to save the file, but its size is 1KB.

Could you, please, give me any tips why does this happens? Any alternative ways of doing this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

any tips why does this happens?

Probably because the browser runs out of memory, when you ask it to create an object URL for an object of such size.

Any alternative ways of doing this?

Don't use AJAX, but instead submit a form with method="post" to send whatever parameters you need for this.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!