s3-readable
v1.0.1
Published
Read S3 files as streams
Downloads
9
Readme
s3-readable
Read S3 files using streams
Installation
$ npm install s3-readable --save
Usage
var fs = require('fs');
var aws = require('aws-sdk');
var readable = require('s3-readable');
aws.config.update({
accessKeyId: process.env.AMAZON_ACCESS_KEY_ID,
secretAccessKey: process.env.AMAZON_ACCESS_KEY_SECRET,
region: process.env.S3_REGION
});
var s3 = new aws.S3();
var stream = readable(s3).createReadStream({
Bucket: 'test',
Key: 'file.pdf'
// takes same params as `s3.getObject`
});
// optionally
stream.on('open', function(file) {
console.log(file); // { ContentLength: 8, ContentType: 'text/plain', Bucket: '...', Key: 'test.txt', Body: self }
});
stream.pipe(fs.createWriteStream(__dirname + '/file.pdf'));
Author
Vladimir Popov [email protected]
License
MIT