async function downloadOneFromS3(bucketName, downloadPath) {
  try {
    /** 1. get data */
    const filedata = await getS3Object(bucketName, downloadPath);
    if (!filedata)
      throw new Error(`Error occurs: S3 getObject does not return file data`);

    /** 2. check dir */
    if (!(await checkDir("d", downloadPath)))
      await mkdirp(path.dirname(downloadPath));

    /** 3. Write file
     * @TODO: USE STREAM version of write file
     */
    await writeFilePromise(downloadPath, filedata.Body.toString("utf-8"));
    return Promise.resolve(true);
  } catch (err) {
    throw new Error(`Error occurs in downloadOneFromS3: ${err.message}`);
  }
}
/** downloadOneFromS3 should download one file from S3 and save it to the local
 * @param bucketName : String
 * @param downloadPath : String (Local file path is the key to the S3 object)
 * Use absolute path
 * @return filedata : Buffer
 * Steps
 * 1. Get the data using the getObject function from S3 SDK
 * 2. Write the file buffer to the target file path
 * 2.1 Check if directory existed, if exists , write file
 * 2.2 If dir not existed, create dir and write file
 */
downloadOneFromS3 should download one file from S3 and save it to the local
@param bucketName : String
@param downloadPath : String (Local file path is the key to the S3 object)
Use absolute path
@return filedata : Buffer
Steps
1. Get the data using the getObject function from S3 SDK
2. Write the file buffer to the target file path
2.1 Check if directory existed, if exists , write file
2.2 If dir not existed, create dir and write file
downloadOneFromS3 should download one file from S3 and save it to the local @param bucketName : String @param downloadPath : String ( Local file path is the key to the S3 object ) Use absolute path @return filedata : Buffer Steps 1 . Get the data using the getObject function from S3 SDK 2 . Write the file buffer to the target file path 2 . 1 Check if directory existed if exists write file 2 . 2 If dir not existed create dir and write file
async function downloadOneFromS3(bucketName, downloadPath) {
  try {
    const filedata = await getS3Object(bucketName, downloadPath);
    if (!filedata)
      throw new Error(`Error occurs: S3 getObject does not return file data`);
    if (!(await checkDir("d", downloadPath)))
      await mkdirp(path.dirname(downloadPath));
    await writeFilePromise(downloadPath, filedata.Body.toString("utf-8"));
    return Promise.resolve(true);
  } catch (err) {
    throw new Error(`Error occurs in downloadOneFromS3: ${err.message}`);
  }
}
async function downloadOneFromS3 ( bucketName , downloadPath ) { try { const filedata = await getS3Object ( bucketName , downloadPath ) ; if ( ! filedata ) throw new Error ( ` ` ) ; if ( ! ( await checkDir ( "d" , downloadPath ) ) ) await mkdirp ( path . dirname ( downloadPath ) ) ; await writeFilePromise ( downloadPath , filedata . Body . toString ( "utf-8" ) ) ; return Promise . resolve ( true ) ; } catch ( err ) { throw new Error ( ` ${ err . message } ` ) ; } }
downloadOneFromS3 should download one file from S3 and save it to the local
 @param bucketName : String
 @param downloadPath : String (Local file path is the key to the S3 object)
 Use absolute path
 @return filedata : Buffer
 Steps
 1.
downloadOneFromS3 should download one file from S3 and save it to the local @param bucketName : String @param downloadPath : String ( Local file path is the key to the S3 object ) Use absolute path @return filedata : Buffer Steps 1 .
/** 1. get data */ /** 2. check dir */ /** 3. Write file
     * @TODO: USE STREAM version of write file
     */