clineamb / gulp-s3-upload

A gulp task to upload/update assets to an S3 account.
62 stars 37 forks source link

Add ability to set custom Content-Encoding header on a per file basis #22

Closed rufman closed 9 years ago

rufman commented 9 years ago

Like metadataMap, manualContentEncoding allows you to set the Content-Encoding header using some arbitrary logic in a function:

    gulp.task("upload", function() {
        gulp.src("./dir/to/upload/**")
        .pipe(s3({
            Bucket: 'example-bucket',
            ACL: 'public-read',
            manualContentEncoding: function(keyname) {
                var contentEncoding = null;

                if (keyname.indexOf('.gz') !== -1) {
                  contentEncoding = 'gzip';
                }
                return contentEncoding;
            }
        }));
    });

This is useful for when S3's auto content encoding detection won't work for you (like when you need to support gzipped files on older browsers where the extension needs to be .gz.js and not .js.gz).

clineamb commented 9 years ago

Thanks for this, and modeling it after metadataMap!