Problem with streamed ZIP file and Windows XP

Discussion in 'Java' started by Robbie, May 9, 2005.

  1. Robbie

    Robbie Guest

    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
    Robbie, May 9, 2005
    #1
    1. Advertising

  2. Robbie

    Chris Uppal Guest

    Robbie wrote:

    > 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
    Chris Uppal, May 9, 2005
    #2
    1. Advertising

  3. Robbie

    Robbie Guest

    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
    Robbie, May 9, 2005
    #3
  4. Robbie

    Robbie Guest

    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
    Robbie, May 9, 2005
    #4
  5. Robbie

    Chris Uppal Guest

    Robbie wrote:

    > 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
    Chris Uppal, May 9, 2005
    #5
  6. Robbie

    Robbie Guest

    Chris Uppal wrote:

    > 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
    Robbie, May 10, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. abcd
    Replies:
    7
    Views:
    499
    Edward Elliott
    May 1, 2006
  2. majj81
    Replies:
    0
    Views:
    318
    majj81
    May 31, 2006
  3. Chris Lambacher

    Re: Add file to zip, or replace file in zip

    Chris Lambacher, Jun 1, 2006, in forum: Python
    Replies:
    0
    Views:
    588
    Chris Lambacher
    Jun 1, 2006
  4. Tore Halset

    streamed zip

    Tore Halset, May 31, 2007, in forum: Java
    Replies:
    4
    Views:
    371
    Tore Halset
    Jun 1, 2007
  5. Roger Martin
    Replies:
    0
    Views:
    3,233
    Roger Martin
    Aug 19, 2008
Loading...

Share This Page