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

281
Visualizações
jquery fileDownload: download multiple files into chunks

I'm using https://github.com/johnculviner/jquery.fileDownload to download an array of files. It seems working:

  for (var index = 0; index < files.length; ++index) {
    var file = files[index];
    $.fileDownload(file)
      .done(function() {
        alert("Done " + file);
      }
    )
      .fail(function() {
        alert("Fail " + file);
      }
    );
  }

How can I download the files in chunks of 5 files at a time? The files are downloading, but no alert is showing for the moment. So I think maybe I have a problem here.

When trying to download 100 files, for example, I want to download 5, then other 5 etc until done for all. Is this possible?

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

0

Download first file

var firstfile = files[0]; //first file id
var downloadresult = downloadFileEx(firstfile);

Then chain other files with jquery then and use array.slice to pick the chunk

var begin=1; // start from second file 
var end=5;

do {

for (var index = begin; index < files.slice(begin, end).length; i++) {
 var file = files[index];
(function (index) {
      downloadresult = downloadresult.then(function() {
        return downloadFileEx(array[index]);
       });
   }(index));
 }
index++;
 }
begin = begin +5; 
end = end + 5;
}
while (end  < files.length);

write the file download functiom

function downloadFileEx(file) {
 return $.fileDownload(file)
      .done(function() {
        alert("Done " + file); // remove this 100 alerts will be blocked by browser, maintain an array of files
      }
    )
      .fail(function() {
        alert("Fail " + file);
      }
    );
}
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