Skip to content

software-eugeneer/gulp-aws-s3-upload

 
 

Repository files navigation

npm npm Dependency Status devDependency Status

gulp-aws-s3-upload

install

npm install gulp-aws-s3-upload -S

Configurable gulp task for uploading to aws-s3 bucket

USAGE

const gulp = require('gulp');
const gulpGzip = require('gulp-gzip');
const gulpFilter = require('gulp-filter');
const gulpAwsS3Upload = require('gulp-aws-s3-upload');

gulp.task(() => {
  const filterGzipFiles = gulpFilter([ '**/*.{css,js}' ], { restore: true });

  return gulp
    .src([
      '**/*'
    ])

    .pipe(filterGzipFiles)
    .pipe(gulpGzip())
    .pipe(filterGzipFiles.restore)

    .pipe(gulpAwsS3Upload({
      onlyNew: process.NODE_ENV !== 'production',
      cache: '.tmp/s3-cache.json',
      headers: { 
        CacheControl: 'max-age=864000, s-maxage=864000, must-revalidate',
        ACL: 'public-read' // don't forget this header if this files are public!
      },
      aws: {
        key: '...',
        secret: '...',
        bucket: '...',
        region: '...'
      }
    }));
});

options

options.onlyNew

Default: false

if true uploader will upload only new files (use cache)

options.public

Default: true

uploader additionally set header 'x-amz-acl': 'public-read'

options.cacheFile

Default: null

file path for caching file

options.cacheByFileName

Default: false

mode for cache

options.aws

Default: {} - required

credentials for s3 bucket.

  • key: '...',
  • secret: '...',
  • bucket: '...',
  • region: '...',

options.uploadPath

Default: ''

options.headers

Default: {}

About

configurable gulp task for uploading to aws-s3 bucket

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%