向Jenkins发布文件失败

时间:2011-08-16 12:59:47

标签: python http-post jenkins multipartform-data

我正在尝试通过multipart / form-data将文件从Python发布到Jenkins。请求正文如下所示:

--===============1849003312==
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: file; name="file0"; filename="meta.xml"

PHhtbD4NCjwveG1sPg0K

--===============1849003312==--

这会导致Jenkins在其结尾处引发异常,但其中最相关的部分如下:

Exception: <br>Stacktrace: <pre>org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly
   at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:381)
   at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
   at org.kohsuke.stapler.RequestImpl.parseMultipartFormData(RequestImpl.java:767)
   at org.kohsuke.stapler.RequestImpl.getSubmittedForm(RequestImpl.java:782)

我的POST请求有什么问题?

修改 请求标头如下:

内容类型:

multipart/form-data; boundary="===============1849003312=="    

MIME-版本:

1.0

1 个答案:

答案 0 :(得分:0)

我认为Content-Disposition: file;应该替换为Content-Disposition: attachment;FileUploadBase的源代码未提及“file”,RFC 2183未将“file”列为内容处置的值。