Problem with streamed ZIP file and Windows XP

R

Robbie

I'm having trouble getting Windows XP to open a ZIP file streamed from
a servlet (via Tomcat).

The ZIP contains 1 or more PDFs but when using Windows XP's built-in
ZIP viewer, the ZIP appears empty. However, WinZip shows the contents
correctly.

I saw this thread about a similar issue:

http://groups.google.co.uk/group/co...q=zip+file+windows+xp&rnum=1#703f3c9e17023e89

But in our case filenames do not have semi-colons in the name.

Has anyone else run into this issue and can anyone offer some
suggestions?

Thanks.


Robbie
 
C

Chris Uppal

Robbie said:
The ZIP contains 1 or more PDFs but when using Windows XP's built-in
ZIP viewer, the ZIP appears empty. However, WinZip shows the contents
correctly. [...]
But in our case filenames do not have semi-colons in the name.

How about backslashes (\) or other "special" characters (< > * ? : | or ") ?

If you have access to a Unix box, or a Windows port of zipinfo (such as that
included with Cygwin), then using
zipinfo -v filename
may give you some useful pointer. As might using the "verify" option in WinZip
(I don't have a copy of WinZip, so I don't know how to invoke that option. I'm
confident that it has one, though).

-- chris
 
R

Robbie

Chris -

Thanks for that - we're testing out these options now.

I've read elsewhere that this can be due to XP (SP 2) thinking that the
ZIP file is an attachment and therefore barring access to it.

However, we've tried taking out the "Content-Disposition" header and
are still seeing this behaviour.


Robbie
 
R

Robbie

After a bit of investigating, I think this problem might be due to the
fact that there are spaces in the path name for files contained in the
ZIP file.

We don't actually need the path to be in the ZIP file so this begs the
question: how does one put ZipEntries into a ZipFile *without* the path
information being retained from the original Files' path on the file
system?


Robbie
 
C

Chris Uppal

Robbie said:
After a bit of investigating, I think this problem might be due to the
fact that there are spaces in the path name for files contained in the
ZIP file.

Spaces in filenames /shouldn't/ cause problems. They don't on my system
(XP-pro but without SP2).

We don't actually need the path to be in the ZIP file so this begs the
question: how does one put ZipEntries into a ZipFile *without* the path
information being retained from the original Files' path on the file
system?

Hmm, how are you creating the zip file ? With the Java ZIP implementation
(java.util.zip.ZipOutputStream and friends) ? If so then it should be pretty
obvious -- just set the name to whatever you want (but ensure that it's unique)
when you add the data.

If not then you are using some other tool or library, and I don't know what its
capabilities might be. I wouldn't be surprised to find that you are using a
utility that can only create ZIP files by adding actual files from the
filesystem, rather than a library that creates ZIP format data in memory out of
other data that is also held in memory. The first approach seems to be the
most common even for code libraries (and is the only one possible for external
utilities, of course).

What do you mean by the 'path information' ? If you are building ZIP files
with embedded filenames like
"C:\this is a test\something.pdf"
then that won't work -- ':' is one of the special characters, and '/' is the
correct separator, not '\' (though Windows does seem to interpret '\' as a
separator in ZIP files). Anyway you don't want even to /think/ about embedding
/absolute/ paths in a ZIP file. The filename should be something like:
"top level/sub dir/something.pdf"
or, merely:
"something.pdf"
Whatever tool you are using should certainly have some way to control this
aspect of how it works -- if not then ditch it.

Another thing that occurs to me is that if you are building your ZIP data from
real files, then the tool you are using to do it may be adding data that
Windows interprets as file-system permissions (probably copied from the source
PDF files). The basic permissions are essentially those of DOS/FAT, and one of
the permission flags says that the file is 'hidden', another marks it as being
a 'system' file. It may be that the entries in the ZIP file have one or other
of these flags set, and that Windows is attempting to honour them (it doesn't
on my system, but then I don't have SP2, and I don't let Windows hide 'hidden'
and 'system' files anyway). There is also a more elaborate extended (and
optional) set of file permissions that can be set, and which may have a similar
effect, but I don't know anything much about that aspect of the system.

-- chris
 
R

Robbie

Chris said:
Spaces in filenames /shouldn't/ cause problems. They don't on my system
(XP-pro but without SP2).

I think you're probably right - but we want to remove this possibility.
Hmm, how are you creating the zip file ? With the Java ZIP implementation
(java.util.zip.ZipOutputStream and friends) ? If so then it should be pretty
obvious -- just set the name to whatever you want (but ensure that
it's unique) when you add the data.

Yes, apologies for that, we are using java.util.zip so we will just
change the name of the file being added.

After your suggestion to use zipinfo to compare WinZip files and files
generated by java.util.zip we did identify some differences and we
still have the problem after removing the path I'll post these to see
whether anyone can spot the differences that are preventing Windows XP
from opening the file.

Thanks again for the input.


Robbie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top