向Jenkins发布文件失败 [英] POSTing file to Jenkins fails
问题描述
我正在尝试通过multipart / form-data将文件从Python发布到Jenkins。请求正文如下所示:
I'm trying to POST a file to Jenkins from Python, via multipart/form-data. The request body looks like this:
--===============1849003312==
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: file; name="file0"; filename="meta.xml"
PHhtbD4NCjwveG1sPg0K
--===============1849003312==--
这会导致Jenkins在其结尾处引发异常,其中最相关的部分如下:
This causes Jenkins to raise an exception on its end however, the most relevant bits of which follow:
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请求有什么问题?
What's wrong with my POST request?
编辑:
请求标题如下:
The request headers are as follows:
内容类型:
multipart/form-data; boundary="===============1849003312=="
MIME-Version:
MIME-Version:
1.0
推荐答案
我相信 Content-Disposition:file;
应该替换为内容 - 处置:附件;
。 FileUploadBase 未提及文件,并且 RFC 2183 不会将file列为content-disposition的值。
I believe the Content-Disposition: file;
should be replaced with Content-Disposition: attachment;
. The source code of FileUploadBase does not mention "file", and RFC 2183 does not list "file" as a value for content-disposition.
这篇关于向Jenkins发布文件失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!