在AWS Gateway

时间:2016-12-14 23:24:04

标签: rest amazon-web-services post amazon-s3 aws-api-gateway

我在S3中创建了一个存储桶,并为此在Gateway上创建了一个API。我尝试将文件发布到s3存储桶。

我的要求是; (我使用Chrome REST客户端/ SOAUPUI等)

POST / HTTP/1.1
HOST: lob-test-api.s3-ap-southeast-2.amazonaws.com
content-type: multipart/form-data; boundary=----WebKitFormBoundarywLoiMiBUjfoSuUjG
content-length: 157

------WebKitFormBoundarywLoiMiBUjfoSuUjG
Content-Disposition: form-data; name="fileUpload6"

[object Object]
------WebKitFormBoundarywLoiMiBUjfoSuUjG--

....

我得到的回应是;

<Error>
<Code>InvalidArgument</Code>
<Message>POST requires exactly one file upload per request.</Message>
<ArgumentName>file</ArgumentName>
<ArgumentValue>0</ArgumentValue>
<RequestId>83C6F58DCEA9A85B</RequestId>
<HostId>w3gxLb1CDJ8xPMUkhOH8sezIYC/OP/uaUHUvBlFQCXg453dkkTivjdhfb/uOZCY5KpUOoqfUeBA=</HostId>
 </Error>

我通过tcpmon路由请求,并将内容类型头部multipart / form-data边界编辑为; ------WebKitFormBoundarywLoiMiBUjfoSuUjG。但我仍然得到同样的错误。

为什么我会收到此错误?

这是一个处理POST请求的简单API。

修改

请求

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryS280VEmBfACBZzzD
Content-Length: 8063
Source message

POST / HTTP/1.1
HOST: lob-test-api.s3-ap-southeast-2.amazonaws.com
content-type: multipart/form-data; boundary=----WebKitFormBoundaryS280VEmBfACBZzzD
content-length: 8063

------WebKitFormBoundaryS280VEmBfACBZzzD
Content-Disposition: form-data; name="fileUpload1"; filename="persistence.xml"
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">


</persistence>
------WebKitFormBoundaryS280VEmBfACBZzzD--

RESPONSE

&LT;

?xml version="1.0" encoding="UTF-8" ?>
<Error>
<Code>InvalidArgument</Code>
<Message>POST requires exactly one file upload per request.</Message>
<ArgumentName>file</ArgumentName>
<ArgumentValue>0</ArgumentValue>
<RequestId>E79843688D0A0D29</RequestId>
<HostId>CbCQjV9Y7I1ocpd9QKhpAEEfH+io31NYZwhadPKTQRPLAjIvRa6w1uSg2API7DBwEieZM99wfGg=</HostId>
 </Error>

0 个答案:

没有答案