Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!