如何修复org.jvnet.mimepull.MIMEParsingException? [英] How can I fix org.jvnet.mimepull.MIMEParsingException?

查看:391
本文介绍了如何修复org.jvnet.mimepull.MIMEParsingException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JAX-RS(Jersey)从AngularJS客户端将图像/doc/xlsx文件上传到服务器端Java时,出现以下异常,

While uploading a image/doc/xlsx file from my AngularJS client to my server-side java using JAX-RS(Jersey) i am getting the following exception,

org.jvnet.mimepull.MIMEParsingException: Reached EOF, but there is no closing MIME boundary.

这是什么?为什么我会收到此例外?我该如何摆脱呢?

What is this? Why I am getting this exception? How can I get rid of this?

注意:适用于扩展名为.txt, .html, .yml, .java, .properties的文件 但不适用于扩展名为.doc, .xlsx, .png, .PNG, .jpeg.. etc.

Note: It works for the files with extension .txt, .html, .yml, .java, .properties But not working for the for the file with extension .doc, .xlsx, .png, .PNG, .jpeg.. etc.

我的服务器端代码:

@POST
@Path("/{name}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String uploadedFiles(@Nonnull @PathParam("name") final String name,
        @FormDataParam("file") final InputStream inputStream,
        @FormDataParam("file") final FormDataContentDisposition content) {
}

推荐答案

我遇到了相同的问题.根据我的研究,该问题与文件类型无关.它与上传文件的大小有一点关系.

I encountered the same issue. Based on my research, the problem has no relation with the file type. It has a little relation with the size of the uploaded file.

我不确定根本原因是否是当上传文件很大时,在文件完全上传到服务器之前,客户端会断开与服务器的连接(例如超时).我也验证了猜测.我的测试步骤是

I'm not sure if the root cause is when the uploading file is very big, before the file is uploaded to the server completely, the client disconnects to the server (such as timeout). And I also verified the guess. My test steps is,

1. In client, upload a very big file.      
2. Before the get the response from server, which means is uploading file; 
   close the test client
3. check the server side, you will see the issue.

因此,要解决此问题,我的解决方案是在客户端添加超时时间.

So To fix it, my solution is add timeout time in client side.

这篇关于如何修复org.jvnet.mimepull.MIMEParsingException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆