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

202
Visualizações
Is it possible to download a BLOB after the preview has been opened in a new tab?

I use the below code to download some binary data (a PDF document) and open result in a new tab:

$.ajax({
    url: this.downloadurl,
    xhrFields: {
        responseType: "blob"
    }
})
.done(blob => {
    var url = URL.createObjectURL(blob);

    //open blob in new tab
    window.open(url);
    
    //additionally, download the document
    var a = $("<a>", {
        href: url,
        download: this.filename,
    }).appendTo(document.body);
    a[0].click();
});

It also downloads the document automatically because I found out that it's not possible to download it using the download icon in the preview. Below is the PDF document preview in Chrome. If I click on the download icon:

enter image description here

It will show this :

enter image description here

Is there a way to prevent this? It looks like the URL can only be used once.

about 4 years ago · Juan Pablo Isaza
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