1.3.0 • Published 4 years ago

@letgowebteam/s3 v1.3.0

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

@letgowebtools/s3

s3 is a utility package that wraps the AWS sdk for some methods. All the functions exported here assume that you have permission to access the corresponding s3 resources.

Installing

npm install @letgowebteam/s3

Usage

downloadS3Object

Useful if you want to download a single file from an S3 bucket to disk by returning a promise. To call this function we need to pass the following required data:

ParameterType
optionsS3.GetObjectRequest
pathToSavestring

Example:

const s3 = require('@letgowebtools/s3');

(async() => {
	const options: S3.GetObjectRequest = {
      Bucket: 'my_bucket',
      Key: 'my_sub_folder/my_file.txt',
  };
	const pathToSave = '/tmp/';
	await s3.downloadS3Object(options, pathToSave);
})();

uploadDirToS3

Uploads the specified folder or its contents only to s3 recursively to the specified S3 bucket. To call this function we need to pass the following required data:

ParameterTypePurpose
dirPathstringOrigin path to upload
removePrefixBucketKeystringPrefix folder to remove
bucketNamestringBucket name where files are goint to be uploaded to

If we only want to upload its contents we will have to pass in the 'removePrefixBucketKey' with the part of the path to remove, otherwise an empty string.

Output types:

OutputType
OutputS3.PutObjectOutput

Example:

const s3 = require('@letgowebtools/s3');

(async() => {
	const dirPath = '/tmp/';
	const removePrefixBucketKey = '/tmp/';
	const bucketName = 'my_bucket';
	const output = await s3.uploadDirToS3(dirPath, removePrefixBucketKey, bucketName);
})();
1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago