Reading data from S3 using Lambda

前端 未结 2 1897
深忆病人
深忆病人 2021-01-31 03:15

I have a range of json files stored in an S3 bucket on AWS.

I wish to use AWS lambda python service to parse this json and send the parsed results to an AWS RDS MySQL d

相关标签:
2条回答
  • 2021-01-31 03:25

    You can use bucket.objects.all() to get a list of the all objects in the bucket (you also have alternative methods like filter, page_sizeand limit depending on your need)

    These methods return an iterator with S3.ObjectSummary objects in it, from there you can use the method object.get to retrieve the file.

    0 讨论(0)
  • 2021-01-31 03:29
    s3 = boto3.client('s3')
    response = s3.get_object(Bucket=bucket, Key=key)
    emailcontent = response['Body'].read().decode('utf-8')
    
    0 讨论(0)
提交回复
热议问题