# s3-proxy-stream

> Simplified s3.getObject() streams

Latest version **1.0.1** (published 2016-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install s3-proxy-stream
pnpm add s3-proxy-stream
yarn add s3-proxy-stream
bun add s3-proxy-stream
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-06-07 |
| First published | 2016-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jonathan Ong |
| Maintainers | jongleberry |
| Keywords | aws, sdk, s3, stream, proxy |

## Links

- npm: https://www.npmjs.com/package/s3-proxy-stream
- Repository: https://github.com/jonathanong/s3-proxy-stream
- Homepage: https://github.com/jonathanong/s3-proxy-stream#readme
- Issues: https://github.com/jonathanong/s3-proxy-stream/issues
- npm.io page: https://npm.io/package/s3-proxy-stream

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [any-promise](https://npm.io/package/any-promise.md) ^1.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-06-07
- 1.0.0 — 2016-03-07
- 0.0.0 — 2016-03-07

## README

# s3-proxy-stream

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

Simplified `s3.getObject()` designed for proxying.

## API

### const get = require('s3-proxy-stream')(s3, options)

```js
const s3 = new AWS.S3({
  // access keys and stuff
  params: {
    Bucket: 'my-bucket', // whichever bucket you are using
  }
})

const get = require('s3-proxy-stream')(s3, {
  // default `s3.getObject()` params
  // you can also set `Bucket` here
  Bucket: 'my-bucket',
})
```

All `options` are defaults for every request.

### get(key, [options]).then(stream => {}).catch(err => {})

Get an object at `key`.
`options` is passed to `s3.getObject()`, except we have an extra field called `.headers`.
Simply pass `request.headers` and the appropriate `s3.getObject()` params will be set.

```js
app.use((req, res, next) => {
  get(req.path, {
    headers: req.headers,
  })
  .then(stream => {
    // set the status code
    res.statusCode = stream.statusCode

    // set the headers
    for (const key of stream.headers) {
      res.setHeader(key, stream.headers[key])
    }

    // no body to pipe
    if (res.statusCode === 304) return

    // pipe the response
    stream.on('error', next).pipe(res)
  })
  // handle errors
  .catch(next)
})
```

#### stream

The stream has the following properties:

- `.status` and `.statusCode` - the status code of the response
- `.headers` - headers of the response

#### error

The error has the following properties:

- `.status` and `.statusCode` - the status code of the response

[npm-image]: https://img.shields.io/npm/v/s3-proxy-stream.svg?style=flat-square
[npm-url]: https://npmjs.org/package/s3-proxy-stream
[travis-image]: https://img.shields.io/travis/jonathanong/s3-proxy-stream/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/jonathanong/s3-proxy-stream
[codecov-image]: https://img.shields.io/codecov/c/github/jonathanong/s3-proxy-stream/master.svg?style=flat-square
[codecov-url]: https://codecov.io/github/jonathanong/s3-proxy-stream
[david-image]: http://img.shields.io/david/jonathanong/s3-proxy-stream.svg?style=flat-square
[david-url]: https://david-dm.org/jonathanong/s3-proxy-stream
[license-image]: http://img.shields.io/npm/l/s3-proxy-stream.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/s3-proxy-stream.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/s3-proxy-stream

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