shreyas K N
shreyas K N

Reputation: 155

upload binary from api gateway to S3 bucket

i was trying to create a rest api which can take zip file as input (PUT requst) and store that on S3.

I'm following the tutorial on http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-content-encodings-examples-image-s3.html

I'm getting 500 error ad the cloudwatch logs are as follows

Verifying Usage Plan for request: c2140431-1a10-11e7-9f32-0df3853848fe. API Key: API Stage: xjjd186a30/rd

API Key authorized because method 'PUT /s3' does not require API Key.

Request will not contribute to throttle or quota limits

Usage Plan check succeeded for API Key and API Stage xjjd186a30/rd

Starting execution for request: c2140431-1a10-11e7-9f32-0df3853848fe

HTTP Method: PUT, Resource Path: /s3

Successfully completed execution

Method completed with status: 500

enter image description here

when i try the api from post man i get

AccessDeniedAccess DeniedF55D45C185A5BF11HXopfmxAxGNvmdi7PRp4c1j/wPYmGVTrkKbGXfZwofLOn7TRBPs3uFjer/2UCIktynKtGeNU1Xw=

my roles i have given AmazonS3FullAccess permission and have assigned the role to api gateway settings and the integration request.

can anyone help please

Upvotes: 1

Views: 3476

Answers (2)

Hari K
Hari K

Reputation: 261

If you want to upload the binary files like mp3,audio, documents etc..., you can add an entry with value multipart/form-data in the Binary support in AWS API Gateway settings and post/put the binary file using the header Content-Type = multipart/form-data from postman or api client. It should work..!!

api gateway-binary support image

Upvotes: 0

Mark Mucha
Mark Mucha

Reputation: 1589

It looks like you are attempting to put to the bucket named rest. Is that the correct bucket?

This documentation will probably be a little more helpful for you: Integrating API with AWS S3

In the example in used in the documentation, a bucket and object are provided in the path override for the PUT item method. These are mapped from the path params folder and item.

Here is a helpful screenshot: enter image description here

Upvotes: 1

Related Questions