By using AWS re:Post, you agree to the Terms of Use
/AWS API Gatway to upload File To S3 without AWS Lambda/

AWS API Gatway to upload File To S3 without AWS Lambda

0

Hi i have create 1 aws api gateway which post file to s3 using aws service integration , api works fine from backend code or postman , but when i am trying to post the api from vue js or any java script , its thorn the CORS error , i have enabled the cors setting , and tested using curl its return CORS header in response .

As per Cloud watch preflight called is failing with 500 .

` 2022-05-25T13:38:14.343+05:30 (18e87194-3f4d-4ecf-b8fc-e6b1069eb878) Method request body before transformations: [Binary Data]

2022-05-25T13:38:14.343+05:30 (18e87194-3f4d-4ecf-b8fc-e6b1069eb878) Execution failed due to configuration error: Unable to transform request`

my vue js code

const article = "Vue POST Request Example" ;

		const headers = {
			"Content-Type":'text/plain'
		};
		axios.put("https://ivdfgjilc5.execute-api.ap-southeast-1.amazonaws.com/devv1/vxpoc-es-appsearch/tests3/tryfinal44.txt", article,headers)
			.then((response) => {
            console.log(response) 
       			 })
			.catch(error => {
				this.errorMessage = error.message;
				console.error("There was an error!", error);
				});

any suggestion on this will be helpful

3 Answers
0
Accepted Answer

hi we able to solve this issue , after discussing with aws support , as problem was not with cors. actual problem was with preflight request was giving 500 which i was mentioned in question . with this error

error Execution failed due to configuration error: Unable to transform request

we figure out Binary media in api setting / was causing the problem in my case , i have changed to image/png and its started working . Thanks for all help.

answered a month ago
0

I am not sure what is causing the error, but why are you uploading through API Gateway? Why not upload directly to S3? Just generate a pre-signed upload URL using a Lambda function and upload directly using that URL. It will reduce the latency and also will bypass API Gateway's 10MB payload limit.

EXPERT
answered a month ago
  • hi i have requirement where i wanted to send event data direct to s3 as text file . so i do not have any file to upload. its actually text data which will store as file . but still i will look ur suggestion .

0
  • yes i enabled the CORS for both , i able to solve it . posting the answer below .

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions