/s3-folder-upload

Upload easily a folder to Amazon Simple Storage Service (S3)

Primary LanguageJavaScript

s3 folder upload

JavaScript Style Guide npm version npm

Little script to upload statics to a S3 bucket by using official Amazon SDK.

AWS Credentials

In order to use this module, you'll need to have AWS Credentials. You can load them, two ways:

  • By passing directly to the method as second parameter.
  • By having a ENV variable with the path to a file with the credentials. The ENV variable is AWS_CREDENTIALS_PATH and it should have accessKeyId, secretAccessKey, region and bucket.

Install

npm install s3-folder-upload -S

In case you want to use the CLI, you can install it globally:

npm install -g s3-folder-upload

Require

const s3FolderUpload = require('s3-folder-upload')
// ES6: import s3UploadFolder from 's3-folder-upload'

const directoryName = 'statics'
// I strongly recommend to save your credentials on a JSON or ENV variables
const credentials = {
  "accessKeyId": "<Your Access Key Id>",
  "secretAccessKey": "<Your Secret Access Key>",
  "region": "<Your Aimed Region>",
  "bucket": "<Your Bucket Name>"
}

s3FolderUpload(directoryName, credentials)

CLI

s3-folder-upload <folder>

Example:
s3-folder-upload statics

For the AWS Credentials you need a ENV variable called AWS_CREDENTIALS_PATH with the path of the file with the needed info.

Wish list

  • Upload a entire folder to S3 instead file
  • Async upload of files to improve time
  • Detect automatically the content type of (limited support)
  • Return the list of files uploaded with the final URL
  • Sub folder support.
  • Better support for parameters with the CLI
  • Improve content type function in order to get more and better types of files
  • Avoid to re-upload files if they didn't change
  • Check if cache is blocking updates of statics on website.