Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mgi166 committed Aug 13, 2017
1 parent c53d735 commit f66a435
Showing 1 changed file with 61 additions and 6 deletions.
67 changes: 61 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,67 @@ Resize image by AWS Lambda
## Features

* Use [Serverless Framework](https://github.com/serverless/serverless#features)
* The image conversion procedure is as follows.
* You upload an image file to `s3://${SOURCE_S3_BUCKET_NAME}/${SOURCE_S3_PREFIX}/xxxx.png`.
* S3 create object-created event. and invoke AWS Lambda function.
* Downloads raw image file from s3 in AWS Lambda.
* Resize the image with ImageMagick(using [gm](https://github.com/aheckmann/gm))
* Uploads the resized image file to `s3://${DEST_S3_BUCKET_NAME}/${DEST_S3_PREFIX}/{26 random chars}.{png|jpg|gif|...}` in AWS Lambda.
* The image conversion by event of s3 object created
* The image conversion endpoint by API Gateway

### The image conversion by event of s3 object created

* You upload an image file to `s3://${SOURCE_S3_BUCKET_NAME}/${SOURCE_S3_PREFIX}/xxxx.png`.
* S3 create object-created event. and invoke AWS Lambda function.
* Downloads raw image file from s3 in AWS Lambda.
* Resize the image with ImageMagick(using [gm](https://github.com/aheckmann/gm))
* Uploads the resized image file to `s3://${DEST_S3_BUCKET_NAME}/${DEST_S3_PREFIX}/{26 random chars}.{png|jpg|gif|...}` in AWS Lambda.

### The image conversion endpoint by API Gateway

Create converted image.

#### URL

* `https://{random}.execute-api.{region}.amazonaws.com/{stages}/api/v1.0/resized_image`
* `{random}`
* Random string determinated by serverless.
* `{region}`
* Region of AWS
* `{stages}`
* Stages of API Gateway deployed by serverless.

#### Method

`POST`

#### Request
##### Headers

None.

##### Parameters

|Name|Type|Required|Detail|Example|
|---|---|---|---|---|
|`source_url`| string | true | URL of source image. | `s3://examples.com/image.png` |
|`resize_option`| string | false | Resize option by imagemagick. See [Resizing or Scaling -- IM v6 Examples](http://www.imagemagick.org/Usage/resize/#resize) | `800x600` |
|`dest_s3_bucket`| string | false | Destination of s3 bucket name | `upload-resized-image-bucket` |
|`dest_s3_prefix`| string | false | Destination of s3 prefix | `upload` |

#### Response
##### Headers

|Key|Value|
|---|---|
|`Content-Type`|`application/json`|

##### Body

```
{
"ETag": "\"a2aeedc65cb3a9398a74801401092c8c\"",
"Location": "https://example-bucket.s3-ap-northeast-1.amazonaws.com/result/01BQCS8J09S1W7VBWCPZ1Z5Z3X.jpeg",
"key": "result/01BQCS8J09S1W7VBWCPZ1Z5Z3X.jpeg",
"Key": "result/01BQCS8J09S1W7VBWCPZ1Z5Z3X.jpeg",
"Bucket": "example-bucket"
}
```

## Required

Expand Down

0 comments on commit f66a435

Please sign in to comment.