Gathering detailed insights and metrics for s3-lambo
Gathering detailed insights and metrics for s3-lambo
Gathering detailed insights and metrics for s3-lambo
Gathering detailed insights and metrics for s3-lambo
npm install s3-lambo
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (99%)
HTML (1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
18 Stars
10 Commits
3 Forks
4 Branches
1 Contributors
Updated on Feb 23, 2025
Latest Version
1.2.0
Package Id
s3-lambo@1.2.0
Unpacked Size
27.25 kB
Size
7.63 kB
File Count
6
NPM Version
9.5.1
Node Version
18.16.0
Published on
Jun 06, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
AWS S3 helpers for Node.js, as fast as a Lambo.
AWS S3 helpers, as fast as a Lambo.
params
and options
of each helper are the same as in the AWS documentation.
aws-sdk
module will automatically check for AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables, so there is no manipulation of any kind of vulnerable credentials.
Go Fast or Go Home.
npm install s3-lambo
npm i -S s3-lambo
In order to run unit tests, you'll need to set AWS_BUCKET
, AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables.
Command to run all tests:
npm test
Full example:
1AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE" \ 2AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \ 3AWS_BUCKET="test-bucket" \ 4npm test
ESLint with Airbnb base rules. See Airbnb JavaScript Style Guide.
npm run lint
Mocha and Chai.
npm test
name | type | description | default | example |
---|---|---|---|---|
AWS_ACCESS_KEY_ID* | AWS | Specifies an AWS access key associated with an IAM user or role. | none | AKIAIOSFODNN7EXAMPLE |
AWS_SECRET_ACCESS_KEY* | AWS | Specifies the secret key associated with the access key. This is essentially the "password" for the access key. | none | wJalrXUtnFEMI/K7MDENG/ bPxRfiCYEXAMPLEKEY |
DEBUG | Debug | Debug mode. See bugbug. | none | s3-lambo:* |
*required
1const s3 = require('s3-lambo'); 2 3// s3 is an object of functions 4const { 5 getObjectContent, 6 getObjectHash, 7 listKeys, 8 upload, 9 uploadFile, 10 uploadDirectory, 11} = require('s3-lambo');
s3-lambo module exports an object of functions. You'll find the complete list of functions below.
s3
<Object> with the following functions.Returns the content of an S3 object.
Note:
ContentType
property, the function will return an object if application/json
is found, a string if it starts with text/
or a buffer.params
<Object> See AWS getObject.AWS_NO_SUCH_KEY
AWS_ERROR
Examples:
1// to be run in an async context 2 3// ContentType is application/json 4await getObjectContent({ 5 Key: 'lambo.json', 6 Bucket: 'my-bucket', 7}); // { aventador: 'V12' } 8 9// ContentType is text/plain 10await getObjectContent({ 11 Key: 'lambo.txt', 12 Bucket: 'my-bucket', 13}); // "Aventador" 14 15// no ContentType, seen as application/octet-stream by default 16await getObjectContent({ 17 Key: 'lambo.js', 18 Bucket: 'my-bucket', 19}); // Buffer
Returns the md5 hash of the S3 object content.
params
<Object> See AWS getObject.AWS_NO_SUCH_KEY
AWS_ERROR
Examples:
1// to be run in an async context 2 3await getObjectHash({ 4 Key: 'lambo.json', 5 Bucket: 'my-bucket', 6}); // "cc49759e9ae4eb66a270bb61b9fb6b32"
List all keys of an S3 bucket.
params
<Object> See AWS listObjectsV2.opts
<Object>
ignoreKeys
<Array> Keys to be ignored. Default: []
ignoreRegExp
<RegExp> Keys to be ignored. Default: null
startSlash
<Boolean> Whether keys listed should start with a slash. Default: false
[]
AWS_ERROR
Examples:
1// to be run in an async context 2 3await listKeys({ 4 Bucket: bucket, 5}); 6 7// [ 8// 'index.css', 9// 'index.html', 10// 'index.js', 11// 'package.json', 12// 'private/lambo.png', 13// 'public/lambo.json', 14// 'sw.js', 15// ] 16 17await listKeys({ 18 Bucket: bucket, 19}, 20{ 21 ignoreKeys: [ 22 'sw.js', 23 ], 24 // ignore keys starting with private/ or ending with .json 25 ignoreRegExp: /(^private\/)|(\.json$)/, 26 startSlash: true, 27}); 28 29// [ 30// '/index.css', 31// '/index.html', 32// '/index.js', 33// ]
Upload content to an S3 bucket at the specified key.
Note:
Content-Type
metadata based on key's extension, set to application/octet-stream
by default (see node-mime-types for more details).params
<Object> See AWS upload.options
<Object> See AWS upload. Default: {}
AWS_ERROR
Examples:
1// to be run in an async context 2 3await upload({ 4 Key: 'lambo.txt', 5 Bucket: 'my-bucket', 6 Body: 'Aventador', 7 CacheControl: 86400, 8}); // true, Content-Type metadata is automatically set to text/plain
Upload a file to an S3 bucket at the specified key using streams.
Note:
Content-Type
metadata based on file's extension, set to application/octet-stream
by default (see node-mime-types for more details).parameters
<Object>
path
<String> Relative or absolute path to a file.params
<Object> See AWS upload.options
<Object> See AWS upload. Default: {}
FS_ERROR
AWS_ERROR
Examples:
1// to be run in an async context 2 3await uploadFile({ 4 path: '../lambo.png', 5 params: { 6 Key: 'private/lambo.png', 7 Bucket: 'my-bucket', 8 Body: buffer, 9 CacheControl: 86400, 10 }, 11}); // true, Content-Type set to image/png
Upload a directory and its subdirectories to an S3 bucket recursively.
Note:
rootKey
is the root AWS key to use, by default it is the bucket root, e.g. saying rootKey
is public/images
and you want to upload /Users/you/my-project/pics
, files will be uploaded to s3://bucket/public/images
, default to ''
;Content-Type
metadata based on file's extension, set to application/octet-stream
by default (see node-mime-types for more details);parameters
<Object>
path
<String> Relative or absolute path to a file.params
<Object> See AWS upload.options
<Object> See AWS upload. Default: {}
rootKey
<String> The root AWS key where to upload the directory's files. Default: ''
ignore
<Array> A list of strings to ignore in the key to upload, could be absolute or relative path to the rootKey
. Default: null
FS_ERROR
AWS_ERROR
Examples:
1// to be run in an async context 2 3// uploading ./dist directory: 4// dist/index.html 5// dist/error.html 6// dist/css/index.css 7// dist/js/index.js 8// dist/js/sw.js 9 10await uploadDirectory({ 11 path: './dist', 12 params: { 13 Bucket: 'my-bucket', 14 }, 15}); // true 16 17// results in the S3 bucket 18// index.html 19// error.html 20// css/index.css 21// js/index.js 22// js/sw.js 23 24// uploading ../lambo directory: 25// lambo/lambo.png 26// lambo/logo/lamborghini.png 27// lambo/models/aventador.png 28// lambo/models/huracan.png 29// lambo/models/urus/urus.png 30// lambo/models/urus/urus_pearl_capsule.png 31// lambo/models/urus/urus_graphite_capsule.png 32 33await uploadDirectory({ 34 path: '../lambo', 35 params: { 36 Bucket: 'my-bucket', 37 CacheControl: 86400, 38 }, 39 rootKey: 'public/images', 40 ignore: ['urus/'], 41}); // true 42 43// results in the S3 bucket 44// public/images/lambo.png 45// public/images/logo/lamborghini.png 46// public/images/models/aventador.png 47// public/images/models/huracan.png
Errors emitted by s3-lambo inherit the native Error prototype with an additional code
property and toString
method.
1{ 2 name, 3 code, 4 message, 5 stack, 6 toString(), 7}
name | code | description | module |
---|---|---|---|
AWSError | |||
AWS_NO_SUCH_KEY | Key in bucket does not exist. | src/index | |
AWS_ERROR | aws-sdk module encountered an error. | src/index | |
FSError | |||
FS_ERROR | An error related to the file system was caught. | src/index | |
LibError | |||
UNKNOWN_ERROR | An unknown error was caugth. | src/index |
This project has a Code of Conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
Please take also a moment to read our Contributing Guidelines if you haven't yet done so.
Please see our Support page if you have any questions or for any help needed.
For any security concerns or issues, please visit our Security Policy page.
MIT.
No vulnerabilities found.
No security vulnerabilities found.