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

228
Visualizações
How to open an S3 pre-signed URL in another tab?

How do I open an S3 file in another tab and not download it? I have this feature that generates a pre-signed URL. The front-end then opens this URL. However, what I would like to happen is to open the file in another tab so that the user can see the file before downloading it.

Backend

  static async downloadFile(req, res, next) {
    s3.getSignedUrl('getObject', {
      Bucket: process.env.BUCKET_NAME,
      Key: req.body.fileName
    }, (error, url) => {
      if (error) {
        res.status(403).json({
          err
        })
      } else {
        res.status(200).json({
          url
        })
      }
    })
  }

Frontend

User.downloadFile(fileName) // HTTP request was made in another file using axios
  .then((res) => {
    window.open(res.data.url)
  })

Any advice is highly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to set contentType of the image to the correct one while uploading the image to s3. like, set contentType to image/png if your image has .png format. If the contentType is not correct or not set then the image will be directly downloaded instead of displaying it in the browser. This should solve your problem.

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