<commit_before>AWS S3 Image Uploader
=====================

[![Build Status](https://img.shields.io/wercker/ci/50fbdf51cf64b01a738379a028b8a885.svg "Build Status")](https://app.wercker.com/project/bykey/50fbdf51cf64b01a738379a028b8a885)
[![npm](https://img.shields.io/npm/dm/s3-uploader.svg)]()
[![npm](https://img.shields.io/npm/v/s3-uploader.svg)]()
[![node](https://img.shields.io/node/v/s3-uploader.svg)]()
[![David](https://img.shields.io/david/turistforeningen/node-s3-uploader.svg)]()

Flexible and efficient resize, rename, and upload images to Amazon S3 disk
storage. Uses the official [AWS Node SDK](http://aws.amazon.com/sdkfornodejs/)
and [GM](https://github.com/aheckmann/gm) for image processing.

[![Join the chat at https://gitter.im/Turistforeningen/node-s3-uploader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Turistforeningen/node-s3-uploader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Install

```
npm install s3-uploader --save
```

## Requirements

* Node.JS >= v0.10
* imagemagic
* AWS credentials environment variables
  * `AWS_ACCESS_KEY_ID`
  * `AWS_SECRET_ACCESS_KEY`

## API

```javascript
var Upload = require('s3-uploader');
```

### new Upload(**string** `awsBucketName`, **object** `opts`)

* **string** `awsBucketName` - name of Amazon S3 bucket
* **object** `opts` - global upload options
  * **string** `awsAccessKeyId` - your AWS access key ID
  * **string** `awsSecretAccessKey` - your AWS secret access key
  * **string** `awsBuckeRegion` - region for you bucket; default "us-east-1"
  * **string** `awsBucketPath` - path within your bucket (ex. "/images")
  * **string** `awsBucketAcl` - default ACL for uploded images
  * **number** `awsMaxRetries` - max number of retries; default 3
  * **number** `awsHttpTimeout` - inactive time (ms) beofre timing out; default 10000
  * **number** `resizeQuality` - default resize quallity
  * **boolean** `returnExif` - return exif data for original image
  * **string** `tmpDir` - directory to store temporary files
  * **number** `workers` - limit number of async workers
  * **string** `url` - custom url for uploaded images (ex. "http://cdn.app.com/")
  * **object[]** `versions` - versions to upload to S3
    * **boolean** `original` - if this is the original image
    * **string** `suffix` - this is appended to the file name
    * **number** `quality` - resized image quality
    * **number** `maxWidth` - max width for resized image
    * **number** `maxHeight` - max height for resized image

#### Example

```javascript
var client = new Upload('my_s3_bucket', {
  awsBucketRegion: 'us-east-1',
  awsBucketPath: 'images/',
  awsBucketAcl: 'public-read',

  versions: [{
    original: true
  },{
    suffix: '-large',
    quality: 80,
    maxHeight: 1040,<commit_msg>Document new AWS configuration options<commit_after>AWS S3 Image Uploader
=====================

[![Build Status](https://img.shields.io/wercker/ci/50fbdf51cf64b01a738379a028b8a885.svg "Build Status")](https://app.wercker.com/project/bykey/50fbdf51cf64b01a738379a028b8a885)
[![npm](https://img.shields.io/npm/dm/s3-uploader.svg)]()
[![npm](https://img.shields.io/npm/v/s3-uploader.svg)]()
[![node](https://img.shields.io/node/v/s3-uploader.svg)]()
[![David](https://img.shields.io/david/turistforeningen/node-s3-uploader.svg)]()

Flexible and efficient resize, rename, and upload images to Amazon S3 disk
storage. Uses the official [AWS Node SDK](http://aws.amazon.com/sdkfornodejs/)
and [GM](https://github.com/aheckmann/gm) for image processing.

[![Join the chat at https://gitter.im/Turistforeningen/node-s3-uploader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Turistforeningen/node-s3-uploader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Install

```
npm install s3-uploader --save
```

## Requirements

* Node.JS >= v0.10
* imagemagic
* AWS credentials environment variables
  * `AWS_ACCESS_KEY_ID`
  * `AWS_SECRET_ACCESS_KEY`

## API

```javascript
var Upload = require('s3-uploader');
```

### new Upload(**string** `awsBucketName`, **object** `opts`)

* **string** `awsBucketName` - name of Amazon S3 bucket
* **object** `opts` - global upload options
  * **number** `resizeQuality` - thumbnail resize quallity (default `70`)
  * **boolean** `returnExif` - return exif data for original image (default `false`
  * **string** `tmpDir` - directory to store temporary files (default `os.tmpdir()`
  * **number** `workers` - number of async workers (default `1`)
  * **string** `url` - custom public url (ex. "http://cdn.app.com/")

  * **object** `aws` - aws specific options
    * **string** `region` - region for you bucket; default "us-east-1"
    * **string** `path` - path within your bucket (ex. "/images")
    * **string** `acl` - default ACL for uploded images
    * **string** `accessKeyId` - AWS access key ID override
    * **string** `secretAccessKey` - AWS secret access key override

> The `aws` object is passed directly to `aws-sdk`. You can add any of [these
> options](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor_details)
> in order to fine tune the connection – if you know what you are doing.

  * **object[]** `versions` - versions to upload to S3
    * **boolean** `original` - if this is the original image
    * **string** `suffix` - this is appended to the file name
    * **number** `quality` - resized image quality
    * **number** `maxWidth` - max width for resized image
    * **number** `maxHeight` - max height for resized image

#### Example

```javascript
var client = new Upload('my_s3_bucket', {
  awsBucketRegion: 'us-east-1',
  awsBucketPath: 'images/',
  awsBucketAcl: 'public-read',

  versions: [{
    original: true
  },{
    suffix: '-large',
    quality: 80,
    maxHeight: 1040,
{'fraction_non_alphanumeric': 0.17313637925111647, 'fraction_numerical': 0.02507729302645139, 'mean_word_length': 4.442056074766355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2291986', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1973, 'n_words': 491}