Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSZip.generate doesn't restrict content using JSZip.root #203

Closed
craigloftus opened this issue Feb 24, 2015 · 1 comment
Closed

JSZip.generate doesn't restrict content using JSZip.root #203

craigloftus opened this issue Feb 24, 2015 · 1 comment

Comments

@craigloftus
Copy link

For a zip file that looks like:

  • a.png
  • subfolder/
    • b.png
    • c.png
    • d.png
var zip = new JSZip();
zip.load(arrayBuffer);
var subfolder = zip.folder('subfolder');
var content = subfolder.generate({type: "blob"});

As JSZip.folder sets the root, I expected that content would be restricted to just the files within subfolder, i.e.:

  • b.png
  • c.png
  • d.png

Instead I just get the original zip contents. I have managed to produce the expected behaviour with:

var subfolder = zip.folder('subfolder');
subfolder.files = subfolder.file(/*/);
var content = subfolder.generate({type: "blob"});
@pixelbucket-dev
Copy link

Same problem here. I try to read contents subfolder wise but I always get the whole zip content. This is quite frustrating and not intuitive. Is this a bug? I hope there can be a fix.

dduponchel added a commit to dduponchel/jszip that referenced this issue Jan 19, 2016
The new forEach method is aware of the root folder level: it will only
show entries that start with `zip.root`.

When used in generate methods, it means the generated zip file will be
restricted to the current subfolder, fix Stuk#203.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants