Skip to content

Instantly share code, notes, and snippets.

@gwsu2008
Last active January 3, 2020 06:18
Show Gist options
  • Save gwsu2008/26d5a9063188ef3c0445eeded48ce1ce to your computer and use it in GitHub Desktop.
Save gwsu2008/26d5a9063188ef3c0445eeded48ce1ce to your computer and use it in GitHub Desktop.
Python read S3 file
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