Skip to content

Commit

Permalink
Merge branch 'use-im-packages'
Browse files Browse the repository at this point in the history
Close: #6 #7 #24 #29
  • Loading branch information
Hans Kristian Flaatten committed Jun 11, 2015
2 parents b71a141 + baeff8b commit d4d2d74
Show file tree
Hide file tree
Showing 5 changed files with 475 additions and 429 deletions.
94 changes: 67 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ AWS S3 Image Uploader
[![Node version](https://img.shields.io/node/v/s3-uploader.svg "Node version")](https://www.npmjs.com/package/s3-uploader)
[![Dependency status](https://img.shields.io/david/turistforeningen/node-s3-uploader.svg "Dependency status")](https://david-dm.org/turistforeningen/node-s3-uploader)

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.
Flexible and efficient image resize, rename, and upload to Amazon S3 disk
storage. Uses the official [AWS Node SDK](http://aws.amazon.com/sdkfornodejs/),
and [im-resize](https://github.com/Turistforeningen/node-im-resize) and
[im-metadata](https://github.com/Turistforeningen/node-im-metadata) 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)

## Changelog

All changes are documentated on the [releases page](https://github.com/Turistforeningen/node-s3-uploader/releases).
Changes for latest release can be [found here](https://github.com/Turistforeningen/node-s3-uploader/releases/latest).

## Install

```
Expand All @@ -37,63 +44,97 @@ var Upload = require('s3-uploader');

* **string** `awsBucketName` - name of Amazon S3 bucket
* **object** `opts` - global upload options
* **number** `resizeQuality` - thumbnail resize quallity (**default** `70`)
* **object** `cleanup`
* **boolean** `original` - remove original image after successful upload (**default**: `false`)
* **boolean** `versions` - remove thumbnail versions after sucessful upload (**default**: `false`)

* **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 (**default** build from `region` and `awsBucketName`)

* **object** `aws` - AWS SDK configuration optsion
* **object** `aws`
* **string** `region` - region for you bucket (**default** `us-east-1`)
* **string** `path` - path within your bucket (**default** `""`)
* **string** `acl` - default ACL for uploded images (**default** `privat`)
* **string** `acl` - default ACL for uploaded images (**default** `privat`)
* **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` - set this to `true` to save the original image
* **string** `suffix` - this is appended to the file name (**default** `""`)
* **number** `quality` - resized image quality (**default** `resizeQuality`)
* **object** `resize`
* **string** `path` - local directory for resized images (**default**: same as original image)
* **string** `prefix` - local file name prefix for resized images (**default**: `""`)
* **integer** `quality` - default quality for resized images (**default**: `70`)

* **object[]** `versions`
* **string** `suffix` - image file name suffix (**default** `""`)
* **number** `quality` - image resize quality
* **number** `maxWidth` - max width for resized image
* **number** `maxHeight` - max height for resized image
* **string** `aspect` - force aspect ratio for resized image (**example:** `4:3`
* **string** `background` - set background for transparent images (**example:** `red`)
* **boolean** `flatten` - flatten backgrund for transparent images
* **string** `awsImageAcl` - access control for AWS S3 upload (**example:** `private`)

* **object** `original`
* **string** `awsImageAcl` - access control for AWS S3 upload (**example:** `private`)

#### Example

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

cleanup: {
versions: true,
original: false
},

original: {
awsImageAcl: 'private'
},

versions: [{
original: true
},{
suffix: '-large',
quality: 80,
maxHeight: 1040,
maxWidth: 1040,
suffix: '-large',
quality: 80
},{
suffix: '-medium',
maxHeight: 780,
maxWidth: 780
maxWidth: 780,
aspect: '4:3',
suffix: '-medium'
},{
suffix: '-small',
maxHeight: 320,
maxWidth: 320
maxWidth: 320,
aspect: '4:3',
suffix: '-small'
},{
maxHeight: 100,
maxWidth: 100,
aspect: '1:1',
suffix: '-thumb1'
},{
maxHeight: 250,
maxWidth: 250,
aspect: '1:1',
suffix: '-thumb2'
}]
});
```

### #upload(**string** `src`, **object** `opts`, **function** `cb`)

* **string** `src` - absolute path to source image to upload
* **string** `src` - path to the image you want to upload

* **object** `opts` - upload config options
* **string** `awsPath` - local override for `opts.aws.path`
* **object** `opts`
* **string** `awsPath` - override the path on AWS set through `opts.aws.path`

* **function** `cb` - callback function (**Error** `err`, **object[]** `versions`, **object** `meta`)
* **Error** `err` - `null` if everything went fine
Expand Down Expand Up @@ -128,4 +169,3 @@ which is used to crate the thumbnails C, D, and E.
```

## [MIT License](https://github.com/Turistforeningen/node-s3-uploader/blob/master/LICENSE)

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"async": "~1.2",
"aws-sdk": "~2.1",
"depd": "~1.0",
"gm": "~1.18"
"im-resize": "~2.0",
"im-metadata": "~2.1"
},
"engines": {
"node": ">=0.10 <0.12"
Expand Down
Loading

0 comments on commit d4d2d74

Please sign in to comment.