Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

539
Vistas
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)?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

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
});
over 4 years ago · Santiago Trujillo Denunciar

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!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda