2개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
0
OK so I just realized that I needed to include the Content-Type header with the request.
fetch(action, {
method: "POST",
headers: {
"Content-Type": "...."
},
body: form
})
But when I set my Content-Type to "multipart/form-data", I'm getting this error:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>MalformedPOSTRequest</Code>
<Message>The body of your POST request is not well-formed multipart/form-data.</Message>
<RequestId>7F543E78F106B3A4</RequestId>
<HostId>YV+rDi49ovxQJhZ9cGAWAxWwHz4g8xBS55gaD/tPN4EgAvrkAnMSbXiXL5m3g9xi+BvE8Rj76fw=</HostId>
</Error
>```
And when I set it to undefined, null or false like what I've read from many sources, I get this:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>PreconditionFailed</Code>
<Message>At least one of the pre-conditions you specified did not hold</Message><Condition>Bucket POST must be of the enclosure-type multipart/form-data</Condition>
<RequestId>E2993D140D291888</RequestId>
<HostId>+HZFLQbfjAWBQ7SY8FXWh4hUarRr2YefjOENWH/Eh7XZzuxyfa5DMy1didMZWhPA14XW3ql47iQ=</HostId>
</Error
>```
Also if I did not specify the Content-Type, I will go back to receiving Invalid JSON error like before
EDIT: Actually, not setting Content-Type leaves my browser to set the correct Content-Type and its boundary. But I'm still getting Invalid JSON error...
답변함 6년 전
0
Ok, sorry. Silly me.
Conditions: [
{ "bucket": "bucket" },
["eq", "$key", 'file'] (<-------- MISSING COMMA)
["content-length-range", 1, 1024 * 1024 * 15],
{"success_action_status": "200"}
]
Problem solved.
Edited by: ionizer on Nov 14, 2017 1:30 AM
답변함 6년 전
관련 콘텐츠
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 6달 전