Node.js module to create and sign URLs to access private resources on Amazon S3
Failed to load latest commit information.
test starting fakes3 tor un tests Feb 28, 2014
.gitignore Initial commit Jul 27, 2012 npm banner Oct 23, 2013
index.js Apparently S3 always uses the same format to sign Oct 11, 2013
local_test.js put and get tests Feb 28, 2014
package.json put and get tests Feb 28, 2014

Amazon S3 url signer

Module to sign urls to allow access to the private resources in the S3


To install

npm install amazon-s3-url-signer

Use example

var sig= require('amazon-s3-url-signer');

var bucket1 = sig.urlSigner('my key', 'my secret');
var bucket1 = sig.urlSigner('my key2', 'my secret2');

var url1 = bucket1.getUrl('GET', 'somefile.png', 'mybucket', 10); //url expires in 10 minutes
var url2 = bucket2.getUrl('PUT', '/somedir/somefile.png', 'mybucketonotheraccount', 10); //url expires in 100 minutes

Local test

If you want to test without an s3 acount you can use

sudo apt-get install rubygems
sudo gem install fakes3  --no-rdoc --no-ri
mkdir s3_files
fakes3 -r s3_files -p 1234

Now a fakes3 server is started. Now we will generate an S3 URL, and push a file to it.

var s3 = require('./index');

var putUrl = s3.urlSigner(123, 'abc', {
  host: '',
  port: 1234
}).getUrl('PUT', 'toto.json', 'my_bucket', 600);

The generated S3 url is:

Now you can use this URL with curl

curl --upload-file package.json ""

Or with request

var fs = require('fs');
var request = require('request');

Or with any http client you like :)

Thank to @Filirom1 for local server changes