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

321
Visualizações
"Access denied" accessing images in myS3 bucket from my express server

I have some problems accessing my S3 images via get request form my express server.

I have a mongo database where I store text information for the items on my webpage and save the image key that I send to my S3 bucket. Now when I try to get all the items and the respective png images, this error came to me:

...aws-sdk\lib\request.js:31
        throw err;
        ^
AccessDenied: Access Denied ...

even if my user authorization in S3 is good.

Because I need to fetch all the items for a productPage component I go like this:

//ROUTER FILE
router.get("/cust/test", async (req, res) => {
  try {
    let tests;
    tests = await Test.find();

    tests.map((t) => {
      const png = t.png;
      const readStream = s3DwnPng(png);

      readStream.pipe(res);
      console.log(png);
    });

    res.status(200).json(tests);
    console.log(tests);
  } catch (err) {
    res.status(500).json(err);
  }
});

//S3 FILE

function s3DwnPng(fileKey) {
  const dwnParams = {
    Bucket: process.env.AWS_BUCKET_NAME,
    Key: `png/${fileKey}`,
  };

  return s3.getObject(dwnParams).createReadStream();
}
exports.s3DwnPng = s3DwnPng;

but this does not work for me. Someone could help me?

And is it worth persisting accessing the images passing throw my server? I'm considering switching to a public policy with private CORS access to make the load on my server lighter, is it really secure to do so?

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