rf00 / minizip-asm.js

Minizip in javascript. Work with password. Demo:
https://rf00.github.io/minizip-asm.js/example/
Other
42 stars 17 forks source link

Unable to Extract #3

Open ChukkapalliSukhesh opened 5 years ago

ChukkapalliSukhesh commented 5 years ago

Created Zip file using append. But unable to extract the zip file. It given 'Blank file' error.

robinhe commented 3 years ago

try below @ChukkapalliSukhesh

// create file
import * as Minizip from 'minizip-asm.js'
import * as fs from 'fs'
var text = Buffer.from("content");
var mz = new Minizip();

mz.append("test.txt", text, {password: "psd"});
fs.writeFileSync("test.zip", Buffer.from(mz.zip()));

// extract file
import * as Minizip from 'minizip-asm.js'
import * as fs from 'fs'
var mz = new Minizip(Buffer.from(fs.readFileSync('test.zip')));

var textBuffer = mz.extract('test.txt', { password: "psd"})
console.log(textBuffer.toString()); // "content"