s3-download-stream
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -23,2 +23,5 @@ var Readable = require('stream').Readable; | ||
this.done = false; | ||
// allow for setting chunkSize = null so that default read amount kicks in | ||
// otherwise, use an optimized chunksize for downloading | ||
this.chunkSize = opts.chunkSize === undefined ? 1024*512 : opts.chunkSize; | ||
this.concurrency = opts.concurrency || 6; | ||
@@ -25,0 +28,0 @@ this.queue = new SimpleQueue(worker, processed, null, this.concurrency) |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"repository": { | ||
@@ -10,0 +10,0 @@ "type": "git", |
@@ -44,2 +44,17 @@ | ||
## API | ||
### var downloader = require('s3-download-stream')(config) | ||
`config` options: | ||
* `client`: [AWS.S3](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html) instance | ||
* `concurrency`: (default `6`) Number of download workers. | ||
* `chunkSize`: (default `512KB`) multiply this by concurrency to get rough MBps. | ||
set to `null` to use chunk size chosen by downstream `read(n)` calls (usually `16KB`) | ||
* `params`: See [AWS docs](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getObject-property) | ||
## License | ||
@@ -46,0 +61,0 @@ |
@@ -8,2 +8,3 @@ | ||
apiVersion: "2006-03-01", | ||
region: "", | ||
secretAccessKey: process.env.S3_SECRET_KEY, | ||
@@ -15,3 +16,4 @@ accessKeyId: process.env.S3_ACCESS_KEY | ||
client: new aws.S3(auth), | ||
concurrency: 6, | ||
chunkSize: 1024*1024, | ||
concurrency: 20, | ||
params: { | ||
@@ -23,2 +25,7 @@ Key: process.env.S3_KEY, | ||
downloader(config).pipe(process.stdout) | ||
var stream = downloader(config); | ||
stream.pipe(process.stdout); | ||
stream.on('error', function(err){ | ||
throw err; | ||
}); |
6913
128
82