1

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

shreyas K N
  • 155
  • 1
  • 3
  • 12
  • Maybe an `amazon` error `[InternalServerError] 500 ` – Hackerman Apr 05 '17 at 15:25
  • Also try using a `post` request instead of `put`...check this http://stackoverflow.com/questions/6273560/put-vs-post-for-files-upload-restful-api-to-be-built-using-zend-framework – Hackerman Apr 05 '17 at 15:29

2 Answers2

1

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

Mark Mucha
  • 1,560
  • 2
  • 12
  • 18
  • 3
    I tried this, and successfully put the audio file, but i couldn't play the same, i think there is some issue with the content type! How can i send the audio file as multipart/form-data to s3 via api gateway? – Sabreena May 03 '17 at 07:26
  • Did you solve how to send the correct content-type to s3 so that the file gets played? – Alberto Dallaporta Jul 12 '19 at 10:14
0

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

Amal T S
  • 3,327
  • 2
  • 24
  • 57
Hari K
  • 251
  • 3
  • 8