Horje
nodejs delete s3 folder Code Example
nodejs delete s3 folder
async function emptyS3Directory(bucket, dir) {
    const listParams = {
        Bucket: bucket,
        Prefix: dir
    };

    const listedObjects = await s3.listObjectsV2(listParams).promise();

    if (listedObjects.Contents.length === 0) return;

    const deleteParams = {
        Bucket: bucket,
        Delete: { Objects: [] }
    };

    listedObjects.Contents.forEach(({ Key }) => {
        deleteParams.Delete.Objects.push({ Key });
    });

    await s3.deleteObjects(deleteParams).promise();

    if (listedObjects.IsTruncated) await emptyS3Directory(bucket, dir);
}




Javascript

Related
how to add space in array in javascript Code Example how to add space in array in javascript Code Example
CalendarTriggerBuilder Code Example CalendarTriggerBuilder Code Example
Calling a Method from Outside of the Component Code Example Calling a Method from Outside of the Component Code Example
the specified value cannot be parsed or is out of range javascript Code Example the specified value cannot be parsed or is out of range javascript Code Example
get values from string with delimiter google script Code Example get values from string with delimiter google script Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8