Skip to content

How to compress an existing, uncompressed zip file #436

Answered by gildas-lormeau
jakeboone02 asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to implement this feature easily in 2 lines of code, you could use the import/export methods of the fs.FS API in zip.js.

Here is below an example of code, it reads an uncompressed zip file and creates a compressed zip file from it.

import * as zip from "https://unpkg.com/@zip.js/zip.js/index.js";

const uncompressedZipData = new Blob([new Uint8Array([
	0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0xBA,
	0x45, 0x40, 0xC8, 0x15, 0x94, 0x86, 0x8A, 0x04, 0x00, 0x00, 0x8A, 0x04,
	0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6C, 0x6F, 0x72, 0x65, 0x6D, 0x2E,
	0x74, 0x78, 0x74, 0x4C, 0x6F, 0x72, 0x65, 0x6D, 0x20, 0x69, 0x70, 0x73,
	0x75, 0x6D, 0x20, 0x64, 0x6F, 0x6C, 0x6F,

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jakeboone02
Comment options

@gildas-lormeau
Comment options

@jakeboone02
Comment options

Answer selected by jakeboone02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants