gulp-s3-upload
Advanced tools
Comparing version 1.1.2 to 1.2.0
# Changelog | ||
## Version 1.2.0 | ||
* Added `manualContentEncoding` option from [pull request #22](https://github.com/clineamb/gulp-s3-upload/pull/22) | ||
## Version 1.1.2 | ||
@@ -5,0 +9,0 @@ |
33
index.js
@@ -33,3 +33,3 @@ var es = require('event-stream') | ||
var keyTransform, keyname, keyparts, filename, | ||
mimetype, mime_lookup_name, metadata | ||
mimetype, mime_lookup_name, metadata, contentEncoding | ||
; | ||
@@ -74,3 +74,3 @@ | ||
keyname = keyname.replace(/\\/g, "/"); // JIC Windows (uses backslashes) | ||
@@ -102,3 +102,3 @@ | ||
if (!options.Metadata && options.metadataMap) { | ||
if (helper.isMetadataMapFn(options.metadataMap)) { | ||
if (helper.isFunction(options.metadataMap)) { | ||
metadata = options.metadataMap(keyname); | ||
@@ -110,6 +110,20 @@ } else { | ||
// === manualContentEncoding =========================== | ||
// Similar to metadataMap to put global / individual | ||
// headers on each file object (only if | ||
// options.ContentEncoding) is undefined. (1.2) | ||
if (!options.ContentEncoding && options.manualContentEncoding) { | ||
if(helper.isFunction(options.manualContentEncoding)) { | ||
contentEncoding = options.manualContentEncoding(keyname); | ||
} else { | ||
contentEncoding = options.manualContentEncoding; | ||
} | ||
} | ||
// === ETag Hash Comparison ============================= | ||
// *NEW* in 1.1; do a local hash comparison to reduce | ||
// the overhead from calling upload anyway. | ||
// Add the option for a different algorithm, JIC for | ||
// Add the option for a different algorithm, JIC for | ||
// some reason the algorithm is not MD5. | ||
@@ -154,7 +168,8 @@ // Available algorithms are those available w/ default | ||
objOpts.Bucket = the_bucket; | ||
objOpts.Key = keyname; | ||
objOpts.Body = file.contents; | ||
objOpts.ContentType = mimetype; | ||
objOpts.Metadata = metadata; | ||
objOpts.Bucket = the_bucket; | ||
objOpts.Key = keyname; | ||
objOpts.Body = file.contents; | ||
objOpts.ContentType = mimetype; | ||
objOpts.Metadata = metadata; | ||
objOpts.ContentEncoding = contentEncoding; | ||
@@ -161,0 +176,0 @@ if (options.uploadNewFilesOnly && !head_data || !options.uploadNewFilesOnly) { |
{ | ||
"name": "gulp-s3-upload", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "A gulp task to asynchronous upload/update assets to an AWS S3 Bucket.", | ||
@@ -18,3 +18,4 @@ "main": "index.js", | ||
"upload", | ||
"asynchronous" | ||
"asynchronous", | ||
"gulpplugin" | ||
], | ||
@@ -21,0 +22,0 @@ "author": "Caroline Amaba <her@carolineamaba.com>", |
# gulp-s3-upload | ||
__Version 1.1.1__ | ||
__Version 1.2.0__ | ||
Use for uploading assets to Amazon S3 servers. | ||
Use for uploading assets to Amazon S3 servers. | ||
This helps to make it an easy gulp task. | ||
@@ -11,6 +11,2 @@ | ||
### What's New in 1.1 | ||
* File uploading is now Asynchronus! | ||
* Reduced overhead in checking if a file is new. | ||
__See full details in the [Changelog](docs/changelog.md).__ | ||
@@ -82,3 +78,3 @@ | ||
### etag_hash | ||
### etag_hash | ||
@@ -89,3 +85,3 @@ Type: `string` | ||
Use this to change the hashing of the files' ETags. The default is MD5. More information on AWS's [Common Response Headers can be found here](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html). You shouldn't have to change this, but AWS says the "ETag may or may not be an MD5 diest of the object data", so this option has been implemented should any other case arise. | ||
Use this to change the hashing of the files' ETags. The default is MD5. More information on AWS's [Common Response Headers can be found here](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html). You shouldn't have to change this, but AWS says the "ETag may or may not be an MD5 diest of the object data", so this option has been implemented should any other case arise. | ||
@@ -97,3 +93,3 @@ | ||
Use this to transform your file names before they're uploaded to your S3 bucket. | ||
Use this to transform your file names before they're uploaded to your S3 bucket. | ||
(Previously known as `name_transform`). | ||
@@ -214,3 +210,41 @@ | ||
#### manualContentEncoding | ||
Type: `string` or `function` | ||
If you want to add a custom content-encoding header on a per file basis, you can | ||
define a function that determines the content encoding based on the keyname. | ||
Defining a `string` is like passing the `s3.putObject` param option `ContentEncoding`. | ||
Example (passing a `string`): | ||
```js | ||
gulp.task("upload", function() { | ||
gulp.src("./dir/to/upload/**") | ||
.pipe(s3({ | ||
Bucket: 'example-bucket', | ||
ACL: 'public-read', | ||
manualContentEncoding: 'gzip' | ||
})); | ||
}); | ||
``` | ||
Example (passing a `function`): | ||
```js | ||
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; | ||
} | ||
})); | ||
}); | ||
``` | ||
## AWS-SDK References | ||
@@ -217,0 +251,0 @@ |
@@ -32,2 +32,3 @@ "use strict"; | ||
'metadataMap', | ||
'manualContentEncoding', | ||
'mimeTypeLookup', | ||
@@ -42,5 +43,5 @@ 'nameTransform', | ||
isMetadataMapFn: function (metadataMap) { | ||
return _.isFunction(metadataMap); | ||
isFunction: function (fn) { | ||
return _.isFunction(fn); | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23657
218
261