Last active
January 3, 2020 06:18
-
-
Save gwsu2008/26d5a9063188ef3c0445eeded48ce1ce to your computer and use it in GitHub Desktop.
Python read S3 file
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
import json | |
import boto3 | |
def lambda_handler(event, context): | |
client = boto3.client('s3') | |
res = client.get_object(Bucket='szabgab', Key='abc.json') | |
content = res["Body"].read() | |
data = json.loads(content) | |
return { | |
'statusCode': 200, | |
'headers': { 'Content-Type': 'application/json' }, | |
#'body': json.dumps({ 'res': str(res) }), | |
#'body': json.dumps({ 'res': str(content) }), | |
'body': json.dumps({ 'res': data }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment