s3-blob-store icon indicating copy to clipboard operation
s3-blob-store copied to clipboard

:cloud: Amazon S3 blob-store

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
    • Parameters
    • createReadStream
      • Parameters
    • createWriteStream
      • Parameters
    • remove
      • Parameters
    • exists
      • Parameters
  • WriteParams
  • Options
    • Properties
  • ReadStreamOptions
  • S3
  • ReadParams

S3BlobStore

Create S3 blob store

Parameters

  • opts Object
    • opts.client S3 S3 client
    • opts.bucket String bucket name

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 key
  • s3opts
  • 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 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