[go: up one dir, main page]
More Web Proxy on the site http://driver.im/Skip to main content

Unzip gzipped file

An example of how to decompress a gzipped file and save it to disk.

Edit on Github
Open the gzipped file for reading
const file = await Deno.open("large_file.json.gz");
Create a new file to write the decompressed data
const outputPath = await Deno.create("large_file.json");
Get the writable stream of the output file
const writableStream = outputPath.writable;
Create a decompression stream for gzip format
const stream = new DecompressionStream("gzip");
Pipe the readable stream of the gzipped file through the decompression stream and then to the writable stream of the output file
file.readable.pipeThrough(stream).pipeTo(writableStream);

Run this example locally using the Deno CLI:

deno run --allow-write --allow-read https://docs.deno.com/examples/scripts/unzip_gzipped_file.ts

Did you find what you needed?

Privacy policy