title: How to download Zip File from an s3 bucket to a local directory within a node.js lambda function
body: <p>I am trying to grab a zip file from s3 and store it in a local directory and then read that directory to ensure that the zip.file is there. Is there a sure-fire way to do this. When I read to see if the file is located in the tmp directory it is not there. </p>
  
  <pre><code>// MAKE DIRECTORIES FOR ZIPPED AND UNZIPPED FOLDER
  const zipDirFolder = await mkdirp(localZippedFolder, { recursive: true });
  const unZipDirFolder = await mkdirp(localUnzippedFolder, { recursive: true });
  
  // VERIFY THAT DIRECTORIES ARE CREATED
  const zipFolderChecker = fs.statSync(zipDirFolder);
  const unZipFolderChecker = fs.statSync(unZipDirFolder);
  console.log('SUCCESS: 2 DIRECTORIES CREATED');
  
  // CREATE STREAMS FOR S3 BUCKET OBJECTS
  const tempFileName = path.join(zipDirFolder, 'downloaded.zip');
  const tempFileDownload = fs.createWriteStream(tempFileName);
  
  // DOWNLOAD ZIP FILE FROM S3 BUCKET TO TEMP FOLDER
  const getS3Object = await s3.getObject(params).createReadStream().pipe(tempFileDownload);
  console.log('SUCCESS: ZIP FILE DOWNLOADED');
  
  // LIST FILES IN ZIP FOLDER DIRECTORY
  await new Promise((resolve, reject) =&gt; {
      fs.readdir(zipDirFolder, (error, files) =&gt; {
          error ? reject(error) : resolve(files);
          console.log(files)
  </code></pre>
  
  <p>any examples on how to fix would be greatly appreciated. </p>