Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-s3-upload

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-s3-upload - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

7

docs/changelog.md
# Changelog
## Version 1.6.0
* Stream support added thanks to [@algesten](https://github.com/algesten) - [PR #34](https://github.com/clineamb/gulp-s3-upload/pull/34)
* [aws-sdk](https://github.com/aws/aws-sdk-js) upgraded.
## Version 1.5.2

@@ -4,0 +11,0 @@ * Update modules

33

index.js

@@ -33,3 +33,3 @@ var es = require('event-stream')

var keyTransform, keyname, keyparts, filename,
mimetype, mime_lookup_name, hash
mimetype, mime_lookup_name, hash, nohash
metadata = null, content_encoding = null

@@ -43,8 +43,2 @@ ;

if(file.isStream()) {
// Not supporting streams.
return callback(new gutil.PluginError(PLUGIN_NAME, 'No stream support.'));
}
// =====================================================

@@ -132,2 +126,6 @@ // ============= METHOD TRANSFORMS & LOOKUPS ===========

if(head_err && head_err.statusCode !== 404) {
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 headObject Error: " + head_err.stack));
}
// === ETag Hash Comparison =============================

@@ -146,9 +144,9 @@ // Do a local hash comparison to reduce

hash = hasha(file._contents, {'algorithm': options.etag_hash});
// Hashing requires us to have the entire contents of
// the file. This is not possible for streams.
nohash = file.isStream() || options.etag_hash == 'none';
if(head_err && head_err.statusCode !== 404) {
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 headObject Error: " + head_err.stack));
}
hash = nohash ? 'nohash' : hasha(file._contents, {'algorithm': options.etag_hash});
if(head_data && head_data.ETag === '"' + hash + '"') {
if(!nohash && head_data && head_data.ETag === '"' + hash + '"') {

@@ -208,2 +206,13 @@ // AWS ETag doesn't match local ETag

// When using streams, the ContentLength must be
// known to S3. This is only possible if the incoming
// vinyl file somehow carries the byte length.
if (file.isStream()) {
if (file.stat) {
objOpts.ContentLength = file.stat.size;
} else {
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 Upload of streamObject must have a ContentLength"));
}
}
gutil.log(gutil.colors.cyan("Uploading ..... "), keyname);

@@ -210,0 +219,0 @@

{
"name": "gulp-s3-upload",
"version": "1.5.2",
"version": "1.6.0",
"description": "A gulp task to asynchronous upload/update assets to an AWS S3 Bucket.",

@@ -20,3 +20,6 @@ "main": "index.js",

"gulpplugin",
"gulpfriendly"
"gulpfriendly",
"streams",
"stream support",
"stream"
],

@@ -30,3 +33,3 @@ "author": "Caroline Amaba <her@carolineamaba.com>",

"dependencies": {
"aws-sdk": "2.2.42",
"aws-sdk": "2.3.3",
"event-stream": "^3.3.2",

@@ -33,0 +36,0 @@ "gulp-util": "^3.0.7",

# gulp-s3-upload
__Version 1.5.2__
__Version 1.6.0__

@@ -377,3 +377,21 @@ Use for uploading assets to Amazon S3 servers.

## Stream Support (**New** in 1.6.0)
When uploading large files you may want to use `gulp.src` without buffers. Normally this plugin calculates an ETag hash of the contents and compares that to the existing files in the bucket. However, when using streams, we can't do this comparison.
Furthermore, the AWS SDK requires us to have a `ContentLength` in bytes of contents uploaded as a stream. This means streams are currently only supported for gulp sources that indicate the file size in `file.stat.size`, which is automatic when using a file system source.
Example:
```js
gulp.task("upload", function() {
gulp.src("./dir/to/upload/**", {buffer:false}) // buffer:false for streams
.pipe(s3({
Bucket: 'example-bucket',
ACL: 'public-read'
}));
});
```
_Added by [@algesten](https://github.com/algesten)_
## AWS-SDK References

@@ -380,0 +398,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc