Replies: 1 comment
-
Here is below an example of code heavily inspired from the test you cited. You can run it here: https://plnkr.co/edit/SkTNcrTq8XL37mQo?preview import {
BlobWriter,
BlobReader,
ZipWriter
} from "https://unpkg.com/@zip.js/zip.js/index.js";
const TEXT_CONTENT = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.";
const TEXT_CONTENT_REPEAT = 1024;
const BLOB = new Blob([new Array(TEXT_CONTENT_REPEAT).fill(TEXT_CONTENT).join("")]);
const writers = [];
main();
async function main() {
const splitZipWriter = blobWriterGenerator();
const zipWriter = new ZipWriter(splitZipWriter);
await Promise.all([
zipWriter.add("lorem1.txt", new BlobReader(BLOB)),
zipWriter.add("lorem2.txt", new BlobReader(BLOB)),
zipWriter.add("lorem3.txt", new BlobReader(BLOB))
]);
await zipWriter.close();
let indexFile = 1;
const listElement = document.createElement("ul");
for (let writer of writers) {
const listItemElement = document.createElement("li");
const anchorElement = document.createElement("a");
anchorElement.href = URL.createObjectURL(await writer.getData())
anchorElement.download = "download.z" + String(indexFile).padStart(2, "0");
anchorElement.textContent = anchorElement.download;
listItemElement.appendChild(anchorElement);
listElement.appendChild(listItemElement);
indexFile++;
}
document.body.appendChild(listElement);
}
function* blobWriterGenerator() {
while (true) {
const writer = new BlobWriter();
writer.maxSize = (8192 - 512) + Math.floor(Math.random() * 1024);
writers.push(writer);
yield writer;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to get the "test-split-zip.js" example to work, however, I am not sure how to download the split zip files once the multipart zip file has been created.
Do you have another example of how to download the split files.
I am assuming that you can download each individual split zip file.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions