Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda