Java Unzipping files from Internet Explorer shows 0 files, but works on other browsers

左心房为你撑大大i 提交于 2020-08-10 20:13:52

问题


I have an app where a file is uploaded through the browser, and java function that unzips and goes through each file. It all works on every browser except for internet explorer.. and it's quite hard to debug because I'm not getting an error, I'm just seeing that the function

ZipInputStream zip = new ZipInputStream(file.getInputStream());

doesn't have any entries when I upload through IE, but it does in all other browsers. The size is just 0. What makes it even more confusing is that it actually did work on IE once, same file and everything just randomly in between all my failed attempts. Feel free to ask to see more of how I am doing something if necessary but as far as I can tell by debugging, all the fields are the same at this point:

ZipInputStream zip = new ZipInputStream(file.getInputStream());
ZipEntry entry;
        while ((entry = zip.getNextEntry()) != null) {

}

The file is the exact same location and has the same value when I run it through the debugger. any ideas why? Is it something closer to the front end even when the file is the same in both?

Here is the front end code:

                                <form name="detailForm" id="detailForm" method="post" action="Upload" enctype="multipart/form-data"  target="_blank">
                                    <td class="class" width="75">2. File:</td>
                                    <td>
                                        <input type="hidden" name="x" id="x" value=""/>
                                        <input type='hidden' name='xsl' value='test/test2/test4.xsl'/>
                                        <fileUpload allowedExtensionList=".zip" maxFileSize="60MB"/>
                                    </td>
                                </form>

This calls an HttpServlet in java that does the following code.

Thanks

EDIT:

In the requests, here is a request coming from a working browser:

=== MimeHeaders ===
cache-control = max-age=0
accept = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-language = en-US,en;q=0.5
content-type = multipart/form-data; boundary=---------------------------7e436f3001a
referer = http://10.0.2.2:8080/example/example/example/example.html?formType=detail&nodeID=774
upgrade-insecure-requests = 1
user-agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19041
accept-encoding = gzip, deflate
host = 10.0.2.2:8080
content-length = 56316
connection = Keep-Alive
cookie = userID=7500; exampleID=; exampleID=0; JSESSIONID=8FD6D884B7F20F666899FD0BA335C865; example=267; exampleID=0; example=0; example=0; example=2020; example=; appName=example

And here is from IE:

=== MimeHeaders ===
accept = text/html, application/xhtml+xml, image/jxr, */*
referer = http://10.0.2.2:8080/example/example/example/example.icml?formType=detail&nodeID=774
accept-language = en-US,en;q=0.5
user-agent = Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
content-type = multipart/form-data; boundary=---------------------------7e41a12720132
accept-encoding = gzip, deflate
host = 10.0.2.2:8080
content-length = 802
connection = Keep-Alive
cache-control = no-cache
cookie = lang=en; example=7500; example=; example=0; JSESSIONID=DF216CFF249310F523FCC70B34A1408C; XSRF-TOKEN=0d41f9cc-1f0f-40bb-ad02-8f39ede5e7f6; example=; example=; example=0; example=parent; example=267; example=0; example=0; example=2020; example=; appName=example

I changed the personal names to 'example' for privacy.

来源:https://stackoverflow.com/questions/62780529/java-unzipping-files-from-internet-explorer-shows-0-files-but-works-on-other-br

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