Awesome
s3-blob-store
Amazon S3 abstract-blob-store
Installation
Install with npm
$ npm install s3-blob-store
Example
var aws = require('aws-sdk');
var s3blobs = require('s3-blob-store');
var client = new aws.S3({
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_SECRET_KEY
});
var store = s3blobs({
client: client,
bucket: 'mybucket'
});
// write to s3
fs.createReadStream('/tmp/somefile.txt')
.pipe(store.createWriteStream({ key: 'somefile.txt' }));
// read from s3
store.createReadStream({ key: 'somefile.txt' })
.pipe(fs.createWriteStream('/tmp/somefile.txt'));
// remove
store.remove({ key: 'somefile.txt' }, function (err) {
// ...
});
// exists
store.exists({ key: 'somefile.txt' }, function (err, exists) {
// ...
});
API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->Table of Contents
S3BlobStore
Create S3 blob store
Parameters
createReadStream
Create read stream
Parameters
opts
(ReadStreamOptions | String) options or object key
Returns ReadableStream readable stream of data for the file in your bucket whose key matches
createWriteStream
Create write stream
Parameters
opts
(Options<WriteParams> | String) options or object keys3opts
done
function (Error, {key: String}) callback
Returns WritableStream writable stream that you can pipe data to
remove
Remove object from store
Parameters
opts
({key: String} | String) options containing object key or just keydone
function (Error) callback
exists
Check if object exits
Parameters
opts
({key: String} | String) options containing object key or just keydone
function (Error, Boolean) callback
WriteParams
S3 putObject
params
Options
Type: Object
Properties
key
String object keyname
String?key
aliasfilename
String?key
aliasparams
S3Params? additional S3 options
ReadStreamOptions
Options
including s3-stream-download
configuration
S3
S3 client
ReadParams
S3 getObject
params