s3-stream-upload

2.0.2 • Public • Published

s3-stream-upload

Build Status Build Status

A writable stream which uploads to Amazon S3 using the multipart file upload API.

Inspired by s3-upload-stream.

Install

npm install s3-stream-upload

Usage

var UploadStream = require("s3-stream-upload");
var S3 = require("aws-sdk").S3;
 
var key = "file.mp3";
var s3 = new S3();
 
fs.readFileStream(__dirname + "/file.mp3")
  .pipe(UploadStream(s3, { Bucket: "my-bucket", Key: key }))
  .on("error", function (err) {
    console.error(err);
  })
  .on("finish", function () {
    console.log("File uploaded!");
  });

API

UploadStream(s3, s3Config, config)

Creates and returns a WritableStream for uploading to S3. Takes an S3 instance, and a s3Config object, which takes the same options as S3.createMultipartUpload. Additional, non-S3 config options may be set on config, listed below:

  • concurrent How many chunks can be sent to S3 concurrently. 1 by default.

Events

  • chunk-uploaded - Emitted when a MPU chunk has been uploaded to S3, with the number of chunks uploaded at this point.
  • All WritableStream events.

Properties

Testing

To run unit tests, run:

npm test

License

MIT License, Copyright (c) 2014 Jordan Santell

Package Sidebar

Install

npm i s3-stream-upload

Weekly Downloads

72,150

Version

2.0.2

License

MIT

Last publish

Collaborators

  • chriskinsman
  • jsantell