s3-readstream
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "s3-readstream", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "AWS s3 readable stream made easy", | ||
@@ -5,0 +5,0 @@ "main": "dist/S3Readstream.js", |
# s3-readstream | ||
AWS S3 Read Stream made easy | ||
Simple wrapper around AWS S3 `getObject()` call to grab a range of bytes allowing smooth and stable streaming! | ||
Simple wrapper around [AWS S3 getObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html) call to grab a range of bytes allowing smooth and stable streaming! | ||
* Simple interface for streaming any size file from AWS S3 | ||
* Easily speed-up, and slow down, the streaming at any point | ||
* All of the functionaly you love with NodeJS Readable streams | ||
* Drop in replacement for `AWS.S3.getObject().createReadStream()` | ||
``` | ||
@@ -29,3 +33,3 @@ npm install s3-readstream | ||
}; | ||
// Instantiate the S3ReadStream in place of s3.getObject().createReadStream()! | ||
// Instantiate the S3ReadStream in place of s3.getObject().createReadStream() | ||
const stream = new S3ReadStream(options); | ||
@@ -40,9 +44,20 @@ }); | ||
You can alse use this `stream` like any other NodeJS Readable stream, setting an event listener is exactly the same: | ||
You can alse use this `stream` like any other [NodeJS Readable stream](https://nodejs.org/api/stream.html#readable-streams), setting an event listener is exactly the same: | ||
```js | ||
stream.on('error', error => { | ||
// Handle error | ||
stream.on('data', (chunk) => { | ||
console.log(`read: ${chunk.toString()}`); | ||
}); | ||
stream.on('end', () => { | ||
console.log('end'); | ||
}); | ||
``` | ||
Use this with `zlib` to handle zipped files! | ||
```js | ||
import {createGunzip} from 'zlib'; | ||
const gzip = createGunzip(); | ||
// pipe into gzip to unzip files as you stream! | ||
stream.pipe(gzip) | ||
``` | ||
You can test this stream in an [example HD video app](https://github.com/about14sheep/awsstreaming) and read a [blog on its origins](https://dev.to/about14sheep/streaming-data-from-aws-s3-using-nodejs-stream-api-and-typescript-3dj0). |
8479
62