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

540
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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