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

537
Views
How to download recently uploaded zip file from s3 bucket based on extension(.zip) using node js

Actually From my application they will generate lot of zip files and uploaded into s3 bucket.

The zip files name will be like dfghgghg5565hgghghgh55.zip, fdfdfdfd44545ghghghg.zip.It can be any name.

So How to download those zip files based on file extension(.zip)?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

If you know the bucket that you're working on you can call ListObjects or ListObjectsv2 on that bucket to get up to 1000 objects from it.

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjects-property

var params = {
  Bucket: 'STRING_VALUE', /* required */
  Delimiter: 'STRING_VALUE',
  EncodingType: url,
  Marker: 'STRING_VALUE',
  MaxKeys: 0,
  Prefix: 'STRING_VALUE',
  RequestPayer: requester
};
s3.listObjects(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
  // put code here to filter out just the .zips, then you can request those files with a GetObject() request
});
about 4 years ago · Santiago Trujillo Report

0

You can call your lambda function manually whenever you want to get information about new files. With this code you will always get the last file modified / created.

s3.listObjects(params, function (err, data) {
if (err)
    console.log(err, err.stack); // an error occurred

var sortArray;

data.Contents.sort(function(a,b) {
    return (b.LastModified > a.LastModified) ? 1 :
    ((a.LastModified > b.LastModified) ? -1 : 0);
});

for(var file of data.Contents){
    if (file.Key.endsWith('.zip')) {
        //extractData(file.Key);
        break;
    }
}

But we can have a problem like this, if there is no new file created, it will happen to extract the same file more than once. I suggest later that using the file delete or find another way to identify that file has already been used.

I hope it helped you!

about 4 years ago · Santiago Trujillo 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!