将文件发布到 Jenkins 失败

发布于 2024-11-30 05:37:02 字数 1085 浏览 0 评论 0原文

我正在尝试通过 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 请求出了什么问题?

编辑: 请求标头如下:

Content-Type:

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

MIME-Version:

1.0

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==--

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)

What's wrong with my POST request?

EDIT:
The request headers are as follows:

Content-Type:

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

MIME-Version:

1.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

も星光 2024-12-07 05:37:02

我认为 Content-Disposition: file; 应该替换为 Content-Disposition: Attachment;FileUploadBase 未提及“文件”,并且 RFC 2183 未将“文件”列为内容处置的值。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文