s3wrap v1.0.1
s3wrap
A simple wrapper around the AWS SDK for S3
Prerequisites
This project requires NodeJS (version 14 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.
$ npm -v && node -v
Environment Variables
Please make sure you have the following environment variables set:
AWS_S3_BUCKET_NAME=your-bucket-name
AWS_REGION=your-region
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_S3_ENDPOINT=your-s3-endpoint
CDN
If you want to use CDN, please make sure you use same bucket name for Domain Name and Bucket Name.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Installation
BEFORE YOU INSTALL: please read the prerequisites
Start with cloning this repo on your local machine:
$ git clone https://github.com/dodysat/s3wrap.git
$ cd s3wrap
To install and set up the library, run:
$ npm install --save s3wrap
Or if you prefer using Yarn:
$ yarn add s3wrap
Usage
checkFileExist
const { checkFileExist } = require("s3wrap");
const params = {
Bucket: "bucket-name",
Key: "file-location",
};
const result = await checkFileExist(params);
generatePresignedUrlUpload
generatePresignedUrlUploadPublic
uploadFileFromBody
uploadFileFromFs
getPresignedUrl
getPublicCdnUrl
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :sunglasses:
Built With
- NPM - Dependency Management
- Node.js - JavaScript runtime
Authors
- Dody Satria - dodysat
See also the list of contributors who participated in this project.
License
MIT License © Dody Satria