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

440
Visualizações
Error: Missing credentials in config - /nodeapp/node_modules/aws-sdk/lib/request.js:31

I'm pulling objects using s3.listObjects() function from the AWS-SDK and I keep getting the following error:

/nodeapp/node_modules/aws-sdk/lib/request.js:31 

Followed by

Error: Missing credentials in config
at IncomingMessage.<anonymous> (/nodeapp/node_modules/aws-sdk/lib/util.js:863:34)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:186:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

This doesn't add up because I have a different route (downloadParam) that retrieves an object from S3 without giving me this error. Additionally, when I log out the objects retrieved from downloadResults route, it appears the objects were retrieved with no issues but i'll still get this error.

I have spent hours on this issue and I can't seem to figure out why this is occurring. I have pasted by code for both routes below, the one that works and the one that doesn't. From what I've gleaned online, this appears to be more of a code issue than an AWS-SDK credentials issue.

  downloadParam: function(app, s3){
app.use('/api', apiRoutes)

apiRoutes.get('/download-param-file', function(req, res, next){
 res.set({'Content-Type':'text/csv'})
  s3.getObject({Bucket: 'some-bucket', Key: 'some-key' + req.query.fileName}, function(err, file){

    if (err) {
      console.log(err);
      return next(err);
    } else {
      return res.send(file.Body.toString());
    }
  })
})
},

downloadResults: function(app, s3){
app.use('/api', apiRoutes)

apiRoutes.get('/download-results-file', function(req, res, next){
   res.set({'Content-type': 'application/zip'})

   var params = {
    Bucket: 'some-bucket',
    Delimiter: '/',
    Prefix: 'some-key'
    };


   var filesArray = []
   var files = s3.listObjects(params).createReadStream()
   var xml = new XmlStream(files)
   xml.collect('Key')

   xml.on('endElement: Key', function(item) {
     filesArray.push(item['$text'].substr(params.Prefix.length))
    })

   xml.on('end', function() {

    res.send(zip(filesArray, req.query.jobName,  params))


  })        
})
}

As of right now downloadParams works as expected but downloadResults does not. Any help would be tremendously appreciated.

This link seems solve an issue similar to mine

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You're not authenticating the call. The bucket does not have permissions to list objects without authentication, whereas it does have permission to download specific files without authentication.

See the Amazon Documentation on adding credentials safely to the instance.

Essentially,

var creds = AWS.Credentials();
creds.accessKeyId = 'AKIAIOSFODNN7EXAMPLE';
creds.secretAccessKey = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY';

AWS.config.credentials = creds;
about 4 years ago · Santiago Trujillo Relatório
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