Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda