Create an API Gateway that serves as an entry point for all incoming API requests.
-
Log in to your AWS Management Console.
-
From the Services menu, find and select API Gateway.
-
Click Create API.
-
Under REST API, click Build.
-
Enter a name and description for the new API, and then click Create API.
-
Click Create resource.
-
Enter {bucket} as the resource name.
-
Select CORS (Cross Origin Resource Sharing), and then click Create resource.
-
To create another resource for bucket, select bucket, and then click Create resource.
-
Enter {filename} as the resource name.
-
Select CORS (Cross Origin Resource Sharing), and then click Create resource.
-
To create a method under filename, select filename, and then click Create method.
-
For the Method type, select PUT.
-
Select AWS service as the integration type.
-
From AWS Region, select the region of your S3 bucket.
-
From AWS service, select Simple Storage Service (S3).
-
Select PUT as the HTTP method.
-
Select Use path override as the action type.
-
In Execution role, paste the ARN for the IAM role that you created earlier.
-
Click Create method.
-
On the PUT-Method Execution page, click Integration request.
-
Click Edit.
-
Expand URL path parameters, and click Add path, and enter these details:
- Name:
bucket
- Mapped from:
method.request.path.bucket
-
Save your changes.
-
Under Integration request, click Edit, and then expand URL path parameters.
-
Click Add path again, and enter these details:
- Name:
filename
- Mapped from:
method.request.path.filename
-
Save your changes.
-
From the navigation menu, click API settings.
-
To allow all the media types, under Binary media types, click Manage media types.
-
Click Add binary media type, and enter */*.
-
Save your changes.
-
Similarly, create the Get and Delete methods under /{bucket}/{filename}.