Created
July 3, 2020 09:18
-
-
Save thanakijwanavit/0e423bb4fcd32777ecf1d87c7b826d57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def uploadImage(event, params): | |
| ''' create a signedurl for client to upload image to s3''' | |
| # extract path (object key) from requester | |
| path = event['path'] | |
| # mock key (please remove when used in lambda) | |
| KEY = '' | |
| PW = '' | |
| s3 = boto3.client('s3', | |
| aws_access_key_id = KEY, | |
| aws_secret_access_key = PW, | |
| ) | |
| #parameters for generating the signedurl | |
| parameters = { | |
| 'Bucket' : 'hatari-expense-image', | |
| 'Key' : path | |
| } | |
| # generate signedurl using s3 sdk | |
| signedUrl = s3.generate_presigned_url( | |
| 'put_object', | |
| Params = parameters, | |
| ExpiresIn = 300 | |
| ) | |
| # return signedurl | |
| return { | |
| 'statusCode' : 200, | |
| 'signedUrl': signedUrl | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment