Wednesday, 26 May 2021

Upload object to s3 using aws api gateway service proxy / API Gateway Proxy for S3 with subdirectories

 

This is guideline how to create the AWS API Gateway

Assumption: S3 bucket name: "us-east-1-dev" and folders: --> light/ --> test_1/ --> pdfs/


Create the REST API

  1. Created a resource proxy
  2. select service proxy 
Resource Name*: proxy
Resource Path*: {proxy+}
Click Create API
select the option: HTTP proxy
Endpoint URL: (key anything) e.g: https://testing.com/{proxy}
click Save

Next, choose "Integration Request" 
  1. Integration type: AWS service
  2. select the desired region
  3. select the desired aws service(s3 in my case)
  4. In subdomain give bucket name (e.g: xxxx-us-east-1-dev)
  5. HTTP method: select "PUT" if you want to upload a object. "GET" if you want to get the object. Here is "PUT"
  6. In path override give Path override: {proxy} (because to pass the bucketname dynamically)
  7. finally for api gateway service proxy we need to add the arn for detail explanation on creation of arn follow the document http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-aws-proxy.html

Next, in the "Method Response"
HTTP Status --> fill "200"

Next, in the "Integration Response"

fill "integration.response.header.Content-Type" for "Mapping value"

--> Save.

Go to Testing:

Select the option "Method" as we selected above.
the PATH, key in the file which you want to get
E.g: light/test_2/pdfs/dummy.txt



No comments:

Post a Comment

Implemented a Service to receive real time message from an API Webhook

 What is the webhook?  Ask Google :) 😅  This is my experience to build a Azure Function HTTP trigger to receive an event from SkyBox API W...