Tutorial: Create a REST API as an Amazon S3 proxy in API Gateway - Amazon API Gateway
Using REST API to upload files to the S3 bucket - BlueGrid : BlueGrid
AIM role
Edit Trust Relationship
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "s3.amazonaws.com"
},
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Next, go to API Gateway --> create a REST API.
Create the folder & item resource
create GET -->
Thank you for sharing these useful notes. If I wanted to get a an image, where and how can I get it? The body of response in your example can show the text but what about a .jpeg file?
ReplyDeleteHow do I put an image in the S3 bucket? where should I call the image from to be put into s3? using a put method?
Thanks a lot
Thank you for your comment.
DeleteTo get the image, I think it is the same but the body would be "binary". Sorry I did not develop to retrieve the image yet. Not sure for this one.
To upload the image, you would use the "PUT" method.
Below sample is uploaded pdf file. For image, I think you could change from .pdf to .jpeg
E.g: curl --request PUT -H "Content-Type: application/pdf" --data-binary "@41032323221_04.pdf" https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/41032323221.pdf