generated from cepdnaclk/eYY-3yp-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from lahirumenik/main
download qr success
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
import boto3 | ||
import base64 | ||
from botocore.exceptions import ClientError | ||
|
||
client=boto3.client('s3') | ||
|
||
def lambda_handler(event, context): | ||
print(event) | ||
|
||
bucket_name='arcombat-qr' | ||
body_dict = json.loads(event['body']) | ||
image_file_name=body_dict['email'] | ||
|
||
try: | ||
response = client.generate_presigned_url('get_object', | ||
Params={'Bucket': bucket_name, | ||
'Key': image_file_name+'.png'}, | ||
ExpiresIn=18000) | ||
except ClientError as e: | ||
logging.error(e) | ||
return None | ||
|
||
return { | ||
'statusCode': 200, | ||
'body': json.dumps({'presigned_url': response}), | ||
} |