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

312
Visualizações
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 à 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