Skip to content

Commit

Permalink
fixes aws-solutions#116 by allowing the outputFormat to be specified …
Browse files Browse the repository at this point in the history
…on the request in Default mode
  • Loading branch information
leviwilson committed Jul 5, 2019
1 parent a1b3eb6 commit ac2e852
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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
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() {
});
});
});
})
})

0 comments on commit ac2e852

Please sign in to comment.