/s3-blob-store

:cloud: Amazon S3 blob-store

Primary LanguageJavaScriptMIT LicenseMIT

s3-blob-store build status install size npm package version github license js semistandard style

Amazon S3 abstract-blob-store

blob-store-compatible

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

Table of Contents

S3BlobStore

Create S3 blob store

Parameters

createReadStream

Create read stream

Parameters

Returns ReadableStream readable stream of data for the file in your bucket whose key matches

createWriteStream

Create write stream

Parameters

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 key
  • done function (Error) callback

exists

Check if object exits

Parameters

WriteParams

S3 putObject params

Options

Type: Object

Properties

  • key String object key
  • name String? key alias
  • filename String? key alias
  • params S3Params? additional S3 options

ReadStreamOptions

Options including s3-stream-download configuration

S3

S3 client

ReadParams

S3 getObject params