npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vestwell/s3-streams

v0.4.1

Published

Use readable/writeable streams for manipulating S3 objects.

Downloads

32

Readme

s3-streams

Support for streaming reads and writes from and to S3 using Amazon's native API.

build status coverage license version downloads

Amazon makes it a giant pain to do anything stream-like when it comes to S3 (given the general restriction that every request needs a Content-Length header). We provide native stream classes (both Readable and Writable) that wrap aws-sdk S3 requests and responses to make your life easier.

IMPORTANT: This library uses the streams3 API. In order to provide compatibility with older versions of node we make use of readable-stream. This is unlikely to have any effect on your code but has not yet been well tested.

If you are using node 0.8 you must ensure your version of npm is at least 1.4.6.

Features:

  • Native read streams,
  • Native write streams,
  • Smart piping.

Usage

npm install s3-streams

Write Streams

Create streams for uploading to S3:

var S3 = require('aws-sdk').S3,
	S3S = require('s3-streams');

var upload = S3S.WriteStream(new S3(), {
	Bucket: 'my-bucket',
	Key: 'my-key',
	// Any other AWS SDK options
	// ContentType: 'application/json'
	// Expires: new Date('2099-01-01')
	// ...
});

Read Streams

Create streams for downloading from S3:

var S3 = require('aws-sdk').S3,
	S3S = require('s3-streams');

var download = S3S.ReadStream(new S3(), {
	Bucket: 'my-bucket',
	Key: 'my-key',
	// Any other AWS SDK options
});

Smart Piping

Smart pipe files over HTTP:

var http = require('http'),
    S3 = require('aws-sdk').S3,
	S3S = require('s3-streams');

http.createServer(function(req, res) {
    var src = S3S.ReadStream(...);
    // Automatically sets the correct HTTP headers
    src.pipe(res);
})

Smart pipe files on S3:

var S3 = require('aws-sdk').S3,
	S3S = require('s3-streams');

var src = S3S.ReadStream(...),
	dst = S3S.WriteStream(...);

// No data ever gets downloaded locally.
src.pipe(dst);

Extras

You can create streams with different settings by creating a partial for the specific S3 instance you have:

var instance = new S3(), s3 = {
	createReadStream: _.partial(S3ReadStream, instance),
	createWriteStream: _.partial(S3WriteStream, instance)
}

var stream = s3.createReadStream({ Bucket: 'my-bucket', Key: 'my-key' });

Existing frameworks:

  • knox (doesn't use native AWS SDK, no true streaming support)
  • s3-upload-stream (doesn't use node streams API, no support for streaming downloads)
  • s3-download-stream (only does downloads, downloads are streamed by S3 part, not by individual buffer chunks)
  • streaming-s3 (overall terrible API; no actual streams)
  • create-s3-object-write-stream (probably one of the better ones)