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

320
Views
Streaming file from S3 using express, NoSuchKey error after file already loaded in browser

I'm attempting to stream images and videos from my S3 bucket to my browser by piping the stream through express. I've got the stream working, but even though it works in the browser I'm still getting NoSuchKey errors every time I make the request.

app.get("/:key", async (req, res) => {
s3.getObject({Bucket: "my-bucket", Key: req.params.key}, (err, data) => {
    if (err){
        console.log("error: ", err)
    }
    else {
        console.log("data: ", data)
        res.set('Content-Type', data.ContentType)
        res.set('Content-Length', data.ContentLength)
        res.status(200)
        let rs = require('stream').Readable.from(data.Body)
        rs.pipe(res)
    }
    
})

// try {
//     s3.getObject({Bucket: "my-bucket", Key: req.params.key}).promise().then(
//         (data) => {
//             console.log("data: ", data)
//             res.set('Content-Type', data.ContentType)
//             res.set('Content-Length', data.ContentLength)
//             res.status(200)
//             let rs = require('stream').Readable.from(data.Body)
//             rs.pipe(res)
//         },
//         (err) => {
//             console.log("error: ", err)
//         }
//     )
    
// }
// catch(err){
//     console.log(err)
// }
})

I've tried using promises with the commented out code with the same result.

output:

error:  NoSuchKey: The specified key does not exist.  
    at Request.extractError (C:\my_path\node_modules\aws-sdk\lib\services\s3.js:710:35)  
    ...
about 4 years ago · Juan Pablo Isaza
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!