Skip to content

Commit 66b571a

Browse files
committed
Correct image
1 parent 48d6217 commit 66b571a

File tree

7 files changed

+9
-7
lines changed

7 files changed

+9
-7
lines changed

s3-lambda-resizing-python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Important: this application uses various AWS services and there are costs associ
3838
## How it works
3939
4040
* Use the AWS CLI upload an image to S3
41-
* If the object is a .jpg or a .png, the code creates a thumbnail and saves it to the target bucket.
41+
* If the object is a .jpeg or a .png, the code creates a thumbnail and saves it to the target bucket.
4242
* The code assumes that the destination bucket exists and its name is a concatenation of the source bucket name followed by the string -resized
4343
4444
==============================================
@@ -48,7 +48,7 @@ Important: this application uses various AWS services and there are costs associ
4848
Run the following S3 CLI command to upload an image to the S3 bucket. Note, you must edit the {SourceBucketName} placeholder with the name of the S3 Bucket. This is provided in the stack outputs.
4949
5050
```bash
51-
aws s3 cp './events/example.jpg' s3://{SourceBucketName}
51+
aws s3 cp './events/white_dog.jpeg' s3://{SourceBucketName}
5252
```
5353

5454
Run the following command to check that a new version of the image has been created in the destination bucket.

s3-lambda-resizing-python/events/event.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"s3SchemaVersion": "1.0",
2121
"configurationId": "828aa6fc-f7b5-4305-8584-487c791949c1",
2222
"bucket": {
23-
"name": "<provide-source-bucket-name-here>",
23+
"name": "s3sourcebuckett",
2424
"ownerIdentity": {
2525
"principalId": "A3I5XTEXAMAI3E"
2626
},
2727
"arn": "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df"
2828
},
2929
"object": {
30-
"key": "<provide-source-object-key-here>",
30+
"key": "white_dog.jpeg",
3131
"size": 1305107,
3232
"eTag": "b21b84d653bb07b05b1e6b33684dc11b",
3333
"sequencer": "0C0F6F405D6ED209E1"
4.54 MB
Loading
File renamed without changes.

s3-lambda-resizing-python/hello_world/app.py renamed to s3-lambda-resizing-python/src/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import boto3
1+
import os
22
import uuid
33
from urllib.parse import unquote_plus
4+
import boto3
45
from PIL import Image
56

67
s3_client = boto3.client('s3')
@@ -19,4 +20,4 @@ def lambda_handler(event, context):
1920
upload_path = '/tmp/resized-{}'.format(tmpkey)
2021
s3_client.download_file(bucket, key, download_path)
2122
resize_image(download_path, upload_path)
22-
s3_client.upload_file(upload_path, '{}-resized'.format(bucket), 'resized-{}'.format(key))
23+
s3_client.upload_file(upload_path, os.getenv('DestinationBucketName'), 'resized-{}'.format(key))
File renamed without changes.

s3-lambda-resizing-python/template.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Resources:
2727
Handler: app.lambda_handler
2828
Runtime: python3.12
2929
MemorySize: 2048
30+
Timeout: 60
3031
Layers:
3132
- !Sub 'arn:aws:lambda:${AWS::Region}:175033217214:layer:graphicsmagick:2'
3233
Policies:
@@ -47,7 +48,7 @@ Resources:
4748
S3Key:
4849
Rules:
4950
- Name: suffix
50-
Value: '.jpg'
51+
Value: '.jpeg'
5152
Outputs:
5253
SourceBucketName:
5354
Value: !Ref SourceBucketName

0 commit comments

Comments
 (0)