Skip to content

Commit

Permalink
file zip bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyou2012 committed Dec 14, 2016
1 parent 577af4b commit f006a68
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ export class File {
const parts = this.makeParts();
const zip = new Zip();
for (const key of Object.keys(parts)) {
zip.file(key, parts[key]);
const paths = key.split('/');
console.log(paths);
const folders = paths.slice(0, -1);
const filename = paths[paths.length - 1];
const folder = folders.reduce(function (parent, name) {
return parent.folder(name);
}, zip);

folder.file(filename, parts[key]);
}
if (type === 'blob' || type === 'base64') {
return zip.generateAsync({ type });
Expand Down

0 comments on commit f006a68

Please sign in to comment.