s3-commons
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

s3-commons

Common helper functions to make using AWS S3 service easier

Usage

const AWS = require('aws-sdk')
const s3 = new AWS.S3()
const s3c = require('s3-commons')
const count = await s3c.deleteRecursive(
    s3, 
    'your-bucket',
    '/folder/to/empty')
const list = await s3c.deleteRecursiveVerbose(
    s3, 
    'your-bucket',
    '/folder/to/empty')

deleteRecursive & deleteRecursiveVerbose

Both async functions delete objects recursively under a dir (or "prefix" according to S3) and returns a Promise (as all async functions do).

The Promise from deleteRecursive resolves to a number that is count of deleted keys. The Promise from deleteRecursiveVerbose resolves to an array of string that is array of deleted keys

Parameters:

  • s3: the S3 service instance
  • bucket: string, bucket name
  • dir: string, the path prefix

Readme

Keywords

none

Package Sidebar

Install

npm i s3-commons

Weekly Downloads

37

Version

1.0.1

License

MIT

Unpacked Size

18.3 kB

Total Files

11

Last publish

Collaborators

  • bingtimren