Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor outputFormat Parameter #117

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# System Files
**/.DS_Store
**/.DS_Store
deployment/dist
deployment/manifest-generator
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export VERSION=my-version # version number for the customized code
```
_Note:_ You would have to create 2 buckets, one named 'my-bucket-name' and another regional bucket named 'my-bucket-name-<aws_region>'; aws_region is where you are testing the customized solution. Also, the assets in bucket should be publicly accessible.

```
* Clone the github repo
```bash
git clone https://github.com/awslabs/serverless-image-handler.git
Expand Down Expand Up @@ -51,6 +50,16 @@ _Note:_ In the above example, the solution template will expect the source code
https://s3.amazonaws.com/my-bucket-name/serverless-image-handler/my-version/serverless-image-handler.template
```

### Docker
If you have docker installed, you can build the distributable as well as run the unit tests with the following command from the root of the repository:

```
docker run --rm -it \
-v $PWD:/development \
-w /development \
amazonlinux:2018.03 ./package.sh $DIST_OUTPUT_BUCKET $TEMPLATE_OUTPUT_BUCKET $VERSION
```

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this so I could locally have a repeatable build from a non-amazonlinux distro

Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
Expand Down
15 changes: 15 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash
set -e

# install prerequisites
yum install -y gcc-c++ make which zip
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
yum install -y nodejs

cd deployment

# tests
./run-unit-tests.sh

# build output package
./build-s3-dist.sh $@
7 changes: 6 additions & 1 deletion source/image-handler/image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class ImageRequest {
this.bucket = this.parseImageBucket(event, this.requestType);
this.key = this.parseImageKey(event, this.requestType);
this.edits = this.parseImageEdits(event, this.requestType);

if (this.requestType === 'Default') {
this.outputFormat = this.decodeRequest(event).outputFormat;
}

this.originalImage = await this.getOriginalImage(this.bucket, this.key)
return Promise.resolve(this);
} catch (err) {
Expand Down Expand Up @@ -235,4 +240,4 @@ class ImageRequest {
}

// Exports
module.exports = ImageRequest;
module.exports = ImageRequest;
5 changes: 3 additions & 2 deletions source/image-handler/test/test-image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('setup()', function() {
the ImageRequest object with the proper values`, async function() {
// Arrange
const event = {
path : '/eyJidWNrZXQiOiJ2YWxpZEJ1Y2tldCIsImtleSI6InZhbGlkS2V5IiwiZWRpdHMiOnsiZ3JheXNjYWxlIjp0cnVlfX0='
path : '/eyJidWNrZXQiOiJ2YWxpZEJ1Y2tldCIsImtleSI6InZhbGlkS2V5IiwiZWRpdHMiOnsiZ3JheXNjYWxlIjp0cnVlfSwib3V0cHV0Rm9ybWF0IjoianBlZyJ9'
}
process.env = {
SOURCE_BUCKETS : "validBucket, validBucket2"
Expand All @@ -45,6 +45,7 @@ describe('setup()', function() {
bucket: 'validBucket',
key: 'validKey',
edits: { grayscale: true },
outputFormat: 'jpeg',
originalImage: Buffer.from('SampleImageContent\n')
}
// Assert
Expand Down Expand Up @@ -644,4 +645,4 @@ describe('getAllowedSourceBuckets()', function() {
});
});
});
})
})