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

103
Visualizações
differentiate between folder or file in aws s3Client.listObjectsV2 response

I'm creating a lambda application in node js to find all the files in s3 folder.

I'm using s3Client.listObjectsV2 to fetch all the keys in s3, I'm getting the below response, I want to filter the resultset to just files. whats the best practises for the same.

{
      Key: 'AttributeModel/',
      LastModified: 2021-12-16T23:47:54.000Z,
      ETag: '"d41d8cd98f0"',
      Size: 0,
      StorageClass: 'STANDARD'
    },
    {
      Key: 'AttributeModel/173b8566-5033-4606-a087-ba93ef2c1467.json',
      LastModified: 2022-01-06T17:34:29.000Z,
      ETag: '"d41d8cd98f0"',
      Size: 68,
      StorageClass: 'STANDARD'
    },
    {
      Key: 'AttributeModel/009d155e-e45d-48a7-9a30-19cabb61479b.json',
      LastModified: 2021-12-17T04:02:36.000Z,
      ETag: '"d41d8cd98f0"',
      Size: 48,
      StorageClass: 'STANDARD'
    }
 
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Are all the files .json? or do you know what are file extensions you will get?

If yes, then you can filter based on whether the key has an extension or not.

 const filteredData = dataReceived.filter(eachItem => eachItem.key.endsWith('.json')
 console.log(filteredData)

You can add OR condition in endsWith method if you have more extensions

Another Method:

 const filteredData = dataReceived.filter(eachItem => !eachItem.key.endsWith('/')
 console.log(filteredData)
about 4 years ago · Juan Pablo Isaza 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