1.1.1 • Published 6 years ago
s3-buddy v1.1.1
s3-buddy
Promisified AWS S3 helper functions
Installation
yarn add s3-buddy
Available Utils
- copyObject
- deleteObjects
- moveObjects Not yet Implemented
- renameObjects Not yet Implemented
Documentation
Common parameters
Name | Type | Description | Example |
---|---|---|---|
config | object | aws-sdk S3 constructor object | {apiVersion: '2006-03-01'} |
rules | object | Additonal properties to be passed | See 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));