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

259
Visualizações
React: How to open PDF in new Tab from Cloud storage without downloading in local pc

I am trying to open pdf from the cloud in a new tab, without downloading it to the local machine.

I tried this way but not working for me. In the new tab, it is giving an error.enter image description here

function readFileInNewTab (fileId) {
    let url = BASE_URL + "api/CMS/Documents/Download/" + fileId;
    const requestOptions = {
        method: 'GET',
        headers: { 'Content-Type': 'application/pdf', ...authHeader(url) },
        credentials: 'include',
        responseType: "blob", // important
    };
    inProgress = true;
    return fetch (url, requestOptions).then(handleResponse)
        .then((response)=> {
            const file = new Blob([response], { type: "application/pdf" });
            //Build a URL from the file
            const fileURL = URL.createObjectURL(file);
            //Open the URL on new Window
            const pdfWindow = window.open();
            pdfWindow.location.href = fileURL;   
        })
        .catch((error) => {
            console.log(error);
        });
} 
about 4 years ago · Santiago Gelvez
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