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

node-s3

v1.1.0

Published

A simple Amazon S3 node.js integration

Downloads

22

Readme

Node S3

A simple Amazon S3 node.js integration.

Build Status

Install

npm install node-s3

Usage

Initialization

First initialize the node-s3 module with a URI to your S3 bucket

var s3Url = 's3://key:secret@your_bucket.s3.amazonaws.com';
var s3 = require('node-s3')(s3Url);

It's important that the key/secret provided have write permissions to the bucket.

Alternatively initialize with an options object:

var options = {
  key: '...',
  secret: '...',
  bucket: '...',
  pathname: '/foo' // optional: prefix all S3 keys with this path
};
var s3 = require('node-s3')(options);

Uploading

Example 1: Upload a body

s3.put('/some-s3-key', body, callback);

Example 2: Pipe an incoming http request directly to S3

http.createServer(function (req, res) {
  var headers = {
    'Content-Length': req.headers['content-length']
  };
  var s3Req = s3.put('/some-s3-key', { headers: headers }, callback);
  req.pipe(s3Req);
}).listen(3000);

API

Common for all functions on the s3 object returned from the node-s3 constructor is that they take up to 3 arguemnts:

  • key - The requested S3 key (required). Will be concatinated with the optional pathname given upon initalization
  • body or options - Optional body or options hash
  • callback - Optional callback called with (err, response, body).

In any case, an instance of curly is returned which you among other things can pipe your data to.

Options or body:

The 2nd argument can either be a string, Buffer og an options hash. The first two should be rather self explanatory, and the options hash can be used to provide custom headers as well as a body to the S3 request:

var options = {
  headers: { ... },
  body: '...'
};

Functions:

  • s3.head(key, options || body, callback) - Perform a HEAD request
  • s3.get(key, options || body, callback) - Perform a GET request
  • s3.post(key, options || body, callback) - Perform a POST request
  • s3.put(key, options || body, callback) - Perform a PUT request
  • s3.del(key, options || body, callback) - Perform a DELETE request

License

MIT