1.1.1 • Published 6 years ago

s3-buddy v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

s3-buddy

Promisified AWS S3 helper functions

NPM

Installation

yarn add s3-buddy

Available Utils

Documentation

Common parameters

NameTypeDescriptionExample
configobjectaws-sdk S3 constructor object{apiVersion: '2006-03-01'}
rulesobjectAdditonal properties to be passedSee usage in each function

copyObject

Summary

const { copyObject } = require('s3-buddy');

const params = {
  config: { // OPTIONAL, DEFAULT: {}, AWS SDK S3 constuctor object
    apiVersion: '2006-03-01',
  },
  copySource: 'STRING', // REQUIRED, DESC: Name/Path of source including bucket name
  targetBucket: 'STRING', // REQUIRED, DESC: Name of target bucket
  targetPrefix: 'STRING', // OPTIONAL, DEFAULT: taken from `copySource`, DESC: Name/Path of target object
  rules: { // OPTIONAL, DEFAULT: `{}`, DESC: Options supported in https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#copyObject-property
    ServerSideEncryption: 'aws:kms',
  },
};
copyObject(params)
  .then(res => console.log('RES', res))
  .catch(err => console.log('ERR', err));

Minimal Example

const { copyObject } = require('s3-buddy');

const params = {
  copySource: 'STRING',
  targetBucket: 'STRING',
  targetPrefix: 'STRING',
};
copyObject(params)
  .then(res => console.log('RES', res))
  .catch(err => console.log('ERR', err));

deleteObjects

Summary

const { deleteObjects } = require('s3-buddy');

const params = {
  config: { // OPTIONAL, DEFAULT: {}, AWS SDK S3 constuctor object
    apiVersion: '2006-03-01',
  },
  Bucket: 'STRING', // REQUIRED, DESC: Name of the bucket
  Quite: 'BOOLEAN', // Optional, DESC: Element to enable quiet mode for the request. When you add this element, you must set its value to true.
  list: 'Array', // OPTIONAL, DEFAULT: taken from `copySource`, DESC: Name/Path of target object
  rules: { // OPTIONAL, DEFAULT: `{}`, DESC: Options supported in https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#deleteObjects-property
    MFA: 'aws:kms',
  },
};

deleteObjects(params)
.then(res => console.log('RES', res))
.catch(err => console.log('ERR', err));

Minimal Example

const params = {
  Bucket: 'STRING',
  list: [
    {
      Key: 'STRING', //REQUIRED
      VersionId: 'STRING', // OPTIONAL
    }
  ],
};
deleteObjects(params)
.then(res => console.log('RES', res))
.catch(err => console.log('ERR', err));
1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago