Skip to content

Commit 770be1c

Browse files
committed
Changed DynamoDB rangeKey & relative settings && update README.MD about binary support && Added file buffer size console log to know binary file buffer is coming well
1 parent d08286e commit 770be1c

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ just run
5151
npm run deploy:prod
5252
```
5353

54+
**IMPORTANT**
55+
56+
![Set API Gateway](https://m7ix47c297.execute-api.us-east-1.amazonaws.com/prod/getImage?id=2017-06-11T03:22:10.250Z&filename=a11ebe37-312f-4178-b43a-517fe801340e&width=800)
57+
58+
You should set lambda-image-manager's API Gateway's binary support option.
59+
60+
At API Gateway setting page, set binary option allow header to "image/*".
61+
Then, **Deploy** API Gateway once again in console dashboard.
62+
5463
## Running the tests
5564

5665
WIP

serverless.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ resources:
5454
AttributeDefinitions:
5555
- AttributeName: fileId
5656
AttributeType: S
57-
- AttributeName: version
57+
- AttributeName: id
5858
AttributeType: S
5959
KeySchema:
6060
- AttributeName: fileId
6161
KeyType: HASH
62-
- AttributeName: version
62+
- AttributeName: id
6363
KeyType: RANGE
6464
ProvisionedThroughput:
6565
ReadCapacityUnits: 5

src/db/model/imageMeta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const imageMetaSchema = new Schema({
77
type: String,
88
hashKey: true,
99
},
10-
version: {
10+
id: {
1111
type: String,
1212
rangeKey: true,
1313
},
14-
id: {
14+
version: {
1515
type: String,
1616
},
1717
fileName: {

src/handlers/uploadImage/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import FilenameMaker from "../../helpers/filenameMaker";
44
const handler: AWSLambda.ProxyHandler = async (event, context, _callback) => {
55
const buffer = new Buffer(event.body as string, "base64");
66
const fileSize = buffer.byteLength;
7+
console.log(fileSize, "=== file buffer size");
78

89
// Size validation
910
if (fileSize > process.env.MAX_SIZE_LIMIT) {

0 commit comments

Comments
 (0)