How can I fix org.jvnet.mimepull.MIMEParsingException?

醉酒当歌 提交于 2020-12-12 10:00:09

问题


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?

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.

My Server side code:

@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) {
}

回答1:


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.




回答2:


OK, I'm only guessing, but I think I can see a pattern here.

  • The file types that are working are text based
  • The file types that are not working are binary

This suggests to me that maybe the problem is that there is some kind of issue with the way that non-text data is being handled by the upload process. Maybe it is being transcoded when it shouldn't be.

Anyway, I suggest that you use some tool like Wireshark to capture the TCP/IP traffic in an upload to see if the upload request body has valid MIME encapsulation.



来源:https://stackoverflow.com/questions/22536054/how-can-i-fix-org-jvnet-mimepull-mimeparsingexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!