Skip to content

Commit bd0b523

Browse files
committed
pulling unnecessary s3 commands
1 parent d4863fa commit bd0b523

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lambda_function.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,23 @@
44
import os
55
import boto3
66
import botocore
7+
import urllib
78

89
#print os.environ
910

1011
# Setup AWS access and S3 buckets
1112
S3OUTBUCKET = os.environ.get('S3OUTBUCKET')
1213
S3INBUCKET = os.environ.get('S3INBUCKET')
13-
TESTS3KEY = '59bf0c6bbb886c5a69d758e3-59bf0c6c301edb5a46a1643c.png' # replace with your object key
14-
s3 = boto3.resource('s3')
15-
try:
16-
s3.Bucket(S3INBUCKET).download_file(TESTS3KEY, '59bf0c6bbb886c5a69d758e3-59bf0c6c301edb5a46a1643c.png')
17-
except botocore.exceptions.ClientError as e:
18-
if e.response['Error']['Code'] == "404":
19-
print("The object does not exist.")
20-
else:
21-
raise
2214

2315
def lambda_handler(event, context):
2416
print "OpenCV version=", cv2.__version__
2517
print "np version=", np.__version__
2618
print "context=", context
2719
print "event=", event
2820

29-
#image_key = event.Records[0].s3.object.key;
30-
#print image_key
21+
bucket = event['Records'][0]['s3']['bucket']['name']
22+
key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'])
23+
print key
3124

3225
return "yay, it works!"
3326

0 commit comments

Comments
 (0)