File tree Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Original file line number Diff line number Diff line change 4
4
import os
5
5
import boto3
6
6
import botocore
7
+ import urllib
7
8
8
9
#print os.environ
9
10
10
11
# Setup AWS access and S3 buckets
11
12
S3OUTBUCKET = os .environ .get ('S3OUTBUCKET' )
12
13
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
22
14
23
15
def lambda_handler (event , context ):
24
16
print "OpenCV version=" , cv2 .__version__
25
17
print "np version=" , np .__version__
26
18
print "context=" , context
27
19
print "event=" , event
28
20
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
31
24
32
25
return "yay, it works!"
33
26
You can’t perform that action at this time.
0 commit comments