Skip to content

Simple node.js application that syncs a local directory with a bucket on S3. Applies cache control and compression.

Notifications You must be signed in to change notification settings

dhcole/s3-publish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

s3-publish

Simple node.js application that syncs a local directory with a bucket on S3.

Makes serving a static website from S3 easy, especially when used with CloudFront for SSL.

Worked by checking a list of remote s3 objects, comparing them with local files in a specified directory, removing files on s3 but not in the folder, and uploading new or replacing other files. Adds a caching header and applies gzip compression to specified files.

configuration

Set configuration as a json file:

{
  "bucket": "my.s3.bucket.name",
  "directory": "/path/to/my/website/_site",
  "compress": "html|css|js|json",
  "cache": "max-age=60"
}
  • bucket an S3 bucket
  • directory local directory to sync with bucket
  • compress regex match for files to apply gzip compression
  • cache Cache-control header value

Uses the AWS Javascript SDK, so it reads your AWS credentials from environment variables or a local file. See more here.

install and run

Run with the config file path (e.g. ~/path-to/config.json) as an argument.

$ npm install
$ node app.js [config file]

About

Simple node.js application that syncs a local directory with a bucket on S3. Applies cache control and compression.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages