This content has been marked as final.
Show 4 replies
-
1. Re: upload zip archive bug : NegativeArraySizeException
antoine_h Nov 28, 2006 1:07 PM (in response to antoine_h)the jira is : http://jira.jboss.com/jira/browse/JBPORTAL-1146
-
2. Re: upload zip archive bug : NegativeArraySizeException
roy.russo Nov 28, 2006 1:30 PM (in response to antoine_h)I dont think the workaround will help here, because whats being passed in is the inputstream from the fileupload. The zipfile class expects a File, so am not sure yet on how to deal with this, but it seems like a definite "bug" that needs to be fixed.
-
3. Re: upload zip archive bug : NegativeArraySizeException
antoine_h Nov 28, 2006 3:14 PM (in response to antoine_h)I am working on this right now.
yes, I've seen it is a bit more complicated...
I have tried it this way :FileItem item = (FileItem) itr.next(); ZipFile zipFile = new ZipFile(item.getName());
in the CMSAdminPortlet code (a copy of it).
and it seems to work.
the FileItem javadoc says getName() is not reliable.
it is working with : Internet Explorer 6 and windows XP.
but not working with opera 8.5. getName() return only the file name, not the base path.
I don't know how to solve this.
may be searching in the zip api (which I don't know that much).
is there a way to store a file temporarily in the jboss temp folder (or some other places). then reopen it with ZipFile ? -
4. Re: upload zip archive bug : NegativeArraySizeException
roy.russo Dec 4, 2006 12:00 PM (in response to antoine_h)I've spent the better part of today playing with this, and researching it... There doesnt seem to be a resolution, just that java's zipinputstream cant read non-standard zips.
This is actually a pretty good site and info: http://mindprod.com/jgloss/zip.html Of course...The following code won't work if ZipOutputStream was used to create the zip file. ZipEntry.getSize will return -1.
So even thought you can change things to use a tempFile and use ZipFile, you still have to do:while (entries.hasMoreElements()) { zipEntry = (ZipEntry)entries.nextElement(); String itemName = zipEntry.getName(); if (!zipEntry.isDirectory()) { long fileSize = zipEntry.getSize();
Its the only way to read the file items, is to getSize, but if it returns -1, then we die again. So even using zipFile wont work.
I'll attach the changed I made to the jira, but for now, am adding some exception handling, as I dont see a workaround at all here.