0

I'm trying to download a zip file from AWS Amazon S3 and download it on lambda. But I cannot find the downloaded file or it's not downloading. The file has all the necessary permissions.

My code:

 const file = require('fs').createWriteStream('/tmp/temp0.zip');
 s3.getObject({
  Bucket: 'myBucket',
  Key: 'temp0.zip',
 }).createReadStream().pipe(file);
 file.on('close', function() {
   fs.readdir('./', (err, files) => {
    files.forEach((file) => {
      console.log('File: ', file);
    });
  });
 });

When I run it, it does not log the file name. I also tried to read tmp folder, and I couldn't. My user has all the necessary permissions to download the file. How can I do this?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Tiago Castro
  • 421
  • 6
  • 20

0 Answers0