I am trying to send a file from client side and receive it through AWS API Gateway to my Lambda function which will then put this file in S3 bucket.
I have used the following as default parameter template in API Gateway
{"image" : $input.params('MediaUrl0')}
How will I receive it in python which looks like: def read_upload_toS3(event, context): s3 = boto3.resource('s3')
You could use the lately introduced $input.body
variable in your mapping template:
{
"body" : "$input.body"
}
You maybe should also check out this discussion on this problem. To receive the body in your python function just do
def my_handler(event, context):
body = event['body']
But if the sole purpose of the function is to upload the file to S3, you could also do this directly with API Gateway: