AWS S3 Tools is a package to make it easier to deal with S3 objects, available on NPM, where you can:
This project was created based on another developed in Python. If you would like to use these methods in Python, visit this repo.
The package is available through NPM, which means you can choose to install it using either npm
or yarn
NPM:
npm install aws-s3-tools
Yarn:
yarn add aws-s3-tools
const exists: boolean = await objectExists("BucketName", "FileName");
const exists: boolean = await bucketExists("BucketName");
await createBucket({Bucket: "BucketName"});
await deleteObject("BucketName", "existingFile.pdf");
await deleteFromPrefix("BucketName", "folder");
const keys = ["folder/test.pdf", "folder/file.csv"];
await deleteFromKeys("BucketName", keys);
await deleteBucket("BucketName");
await downloadObject("BucketName","existingFile.pdf", "downloadedFile.pdf");
const keysList: string[] = await listObjects("BucketName", "FolderName");
await moveObject("SourceBucketName", "SourceFileKey", "DestinationBucketName", "DestinationFileKey");
await moveObjects("SourceBucketName", ["SourceFileKey"], "DestinationBucketName", ["DestinationFileKey"]);
await uploadObject("BucketName","s3file.pdf", "localFile.pdf");
await uploadObjects("BucketName",[{ key: "s3file.pdf", localFilename: "localFile.pdf" }]);
await uploadFolderToPrefix("BucketName", "s3Folder", "localFolder");
The documentation for each method supported by this module can be found here.
To use this package, it's necessary to authenticate to AWS, using one of three options:
AWS.config.loadFromPath("./config.json");
// call methods
For more information, visit Authenticate with json file.
AWS.config.credentials = new AWS.SharedIniFileCredentials({profile: 'work-account'});
// call methods
For more information, visit Authenticate with Shared Credentials file.
AWS.config.update({
accessKeyId: CLIENT_ID,
secretAccessKey: CLIENT_SECRET,
region: REGION
});
// call methods
For more information, visit Authenticate with Environment Variables.To run the tests for this project:
NPM:
npm run test
Yarn:
yarn test
If you encounter any problems, bugs or other issues with the package, please create an issue in the GitHub repo.
Generated using TypeDoc