Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!