0.0.4 • Published 4 years ago
aws-s3-count v0.0.4
AWS S3 Count
This package is to calculate the size of the existing folder AWS S3.
Install
With yarn
yarn add aws-s3-count
or npm
npm install aws-s3-count
Example Usage
const s3Count = require('aws-s3-count');
// Declare your S3 Conifg
const config = {
accessKeyId: 'myAccessKeyId',
secretAccessKey: 'mySecretAccessKey',
endpoint: 'https://example-url.com',
bucket: 'my-bucket',
};
// Using promise
s3Count('publics/', false, config).then((data) =>
console.log('Total Size', data, 'Bytes')
);
// Using async / await
const count = async () => {
const size = await s3Count('publics/', false, config);
console.log('Total Size', size, 'Bytes');
return size;
};
Parameters
There are 3 paramaters you must passing.
s3Count(first, second, third)
Parameters:
first (String)
: Folder inside bucket will be count. Example:publics/
,publics/sub_folder/
.second (boolean)
: By default settrue
. If true. will calculating all sub folder that you declare path folder inside first parameter. Iffalse
, will calculating current folder.third (object)
: Config AWS S3, you can see like example above.