# amazon-s3-url-signer

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

Latest version **0.1.0** (published 2016-12-13) · BSD license · 0 weekly downloads

## Install

```sh
npm install amazon-s3-url-signer
pnpm add amazon-s3-url-signer
yarn add amazon-s3-url-signer
bun add amazon-s3-url-signer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-12-13 |
| First published | 2012-07-27 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 71 |
| Author | Dmytro Yashkir |
| Maintainers | dyashkir |
| Keywords | amazon, S3, url, signing |

## Links

- npm: https://www.npmjs.com/package/amazon-s3-url-signer
- Repository: https://github.com/dyashkir/amazon-s3-url-signer
- Issues: https://github.com/dyashkir/amazon-s3-url-signer/issues
- npm.io page: https://npm.io/package/amazon-s3-url-signer

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-12-13
- 0.0.7 — 2013-10-11
- 0.0.6 — 2013-04-19
- 0.0.5 — 2012-11-16
- 0.0.4 — 2012-08-13
- 0.0.3 — 2012-08-13
- 0.0.2 — 2012-07-27
- 0.0.1 — 2012-07-27

## README

##Amazon S3 url signer

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

[![NPM](https://nodei.co/npm/amazon-s3-url-signer.png)](https://nodei.co/npm/amazon-s3-url-signer/)

###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 bucket2 = 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', 100); //url expires in 100 minutes

###Local test

If you want to test without an s3 acount you can use <https://github.com/jubos/fake-s3>.

    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: 'mymachine.me',
      port: 1234
    }).getUrl('PUT', 'toto.json', 'my_bucket', 600);
    console.log(putUrl);

The generated S3 url is:

    http://mymachine.me:1234/my_bucket/toto.json?Expires=1352966881&AWSAccessKeyId=123&Signature=FDs%2Buf0hXskY1%2BUj4A7S4wHFx20%3D

Now you can use this URL with curl

    curl --upload-file package.json "http://mymachine.me:1234/my_bucket/toto.json?Expires=1352966881&AWSAccessKeyId=123&Signature=FDs%2Buf0hXskY1%2BUj4A7S4wHFx20%3D"

Or with request

    var fs = require('fs');
    var request = require('request');
    fs.createReadStream('file.json').pipe(request.put("http://mymachine.me:1234/my_bucket/toto.json?Expires=1352966881&AWSAccessKeyId=123&Signature=FDs%2Buf0hXskY1%2BUj4A7S4wHFx20%3D"))

Or with any http client you like :)

Thank to @Filirom1 for local server changes

---
_Source: https://npm.io/package/amazon-s3-url-signer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
