Touffy / client-zip

A client-side streaming ZIP generator
MIT License
342 stars 22 forks source link

[BUG] file does not appear in the ZIP #11

Closed a-tonchev closed 3 years ago

a-tonchev commented 3 years ago

Describe the bug When I zip file that has name with upper case letters - it won't work.

To Reproduce Steps to reproduce the behavior:

const file= new File( [ imageBlob ], 'something.JPG' ); const blob = await downloadZip( [ ...someotherfiles, file ] ).blob(); FileSaver.saveAs( blob, 'myFile.zip' );

The JPG file is missing

Expected behavior The jpg file should be in the zipped file 'myFile.zip' .

If I try with lower-case 'something.jpg', then it works

Touffy commented 3 years ago

Do you see this bug only with manually created Files ? What happens if you use a file input to load a file with an uppercase name from your filesystem ? how about an input object like this:

{ name: 'something.JPG', input: imageBlob }
a-tonchev commented 3 years ago

@Touffy The problem was that there is a whitespace at the beginning of the file.

So it does not depend on upper/lower case...

When I create new file with whitespace

const file= new File( [ imageBlob ], ' something.JPG' );

The filename is automatically fixed in the blob, but it does not appear in the zip file.

So I will close this for now

Touffy commented 3 years ago

I've tried with space-prefixed file names and it seems that client-zip includes them properly in the archive. Do you perhaps have a local filesystem that doesn't allow such filenames, so the bug actually occurs when unzipping ?

a-tonchev commented 3 years ago

@Touffy I use Windows 10, did you try with spaces at end?

Touffy commented 3 years ago

I did, just now. It unzips fine on my Mac. Of course macOS is unable to infer the file type from an extension with trailing spaces so it shows it as a binary executable.