Comparing version 0.8.8 to 0.8.9
@@ -51,4 +51,28 @@ var fs = require('fs'); | ||
return directory(source); | ||
}, | ||
s3 : function(client,params) { | ||
var source = { | ||
size: function() { | ||
return new Promise(function(resolve,reject) { | ||
client.headObject(params, function(err,d) { | ||
if (err) | ||
reject(err); | ||
else | ||
resolve(d.ContentLength); | ||
}); | ||
}); | ||
}, | ||
stream: function(offset,length) { | ||
var d = {}; | ||
for (var key in params) | ||
d[key] = params[key]; | ||
d.Range = 'bytes='+offset+'-' + (length ? length : ''); | ||
return client.getObject(d).createReadStream(); | ||
} | ||
}; | ||
return directory(source); | ||
} | ||
}; | ||
{ | ||
"name": "unzipper", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"description": "Unzip cross-platform streaming API ", | ||
@@ -37,2 +37,3 @@ "author": "Evan Oxfeld <eoxfeld@gmail.com>", | ||
"devDependencies": { | ||
"aws-sdk": "^2.77.0", | ||
"request": "^2.79.0", | ||
@@ -39,0 +40,0 @@ "tap": ">= 0.3.0 < 1", |
@@ -64,3 +64,3 @@ # unzipper [![Build Status](https://api.travis-ci.org/ZJONSSON/node-unzipper.png)](https://api.travis-ci.org/ZJONSSON/node-unzipper) | ||
objectMode: true, | ||
_transform: function(entry,e,cb) { | ||
transform: function(entry,e,cb) { | ||
var fileName = entry.path; | ||
@@ -185,3 +185,26 @@ var type = entry.type; // 'Directory' or 'File' | ||
### Open.s3([aws-sdk], [params]) | ||
This function will return a Promise to the central directory information from a zipfile on S3. Range-headers are used to avoid reading the whole file. Unzipper does not ship with with the aws-sdk so you have to provide an instanciated client as first arguments. The params object requires `Bucket` and `Key` to fetch the correct file. | ||
Example: | ||
```js | ||
var unzipper = require('./unzip'); | ||
var AWS = require('aws-sdk'); | ||
var s3Client = AWS.S3(config); | ||
unzipper.Open.s3(s3Client,{Bucket: 'unzipper', Key: 'archive.zip'}) | ||
.then(function(d) { | ||
console.log('directory',d); | ||
return new Promise(function(resolve,reject) { | ||
d.files[0].stream() | ||
.pipe(fs.createWriteStream('firstFile')) | ||
.on('error',reject); | ||
.on('finish',resolve) | ||
}); | ||
}); | ||
``` | ||
## Licenses | ||
See LICENCE | ||
See LICENCE |
Sorry, the diff of this file is not supported yet
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
34922
744
209
6