rf00 / minizip-asm.js Goto Github PK
View Code? Open in Web Editor NEWMinizip in javascript. Work with password. Demo:
Home Page: https://rf00.github.io/minizip-asm.js/example/
License: Other
Minizip in javascript. Work with password. Demo:
Home Page: https://rf00.github.io/minizip-asm.js/example/
License: Other
// 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'))); // fails here
var textBuffer = mz.extract('test.txt', { password: "psd"})
console.log(textBuffer.toString()); // "content"
I have testing this library and created many files however at random a few of the zip files created throw up this error. I have not been able to find out what is specific to those files. I am including the code and the point where the error appears
// read the buffer from file object
const _filebuffer = await this._readBuffer(fileobj);
// convert to uint8array
const _arr = new Uint8Array(_filebuffer);
// create new object using arr
this._zip = new Minizip(_arr);
// read list of zip content
const _list = this._zip.list();
At the point of list()
the library inconsistently throws up
Error: error with zipfile in unzGoToFirstFile
at Minizip.list
Any help on why this happens will be greatly appreciated. Thanks
Created Zip file using append.
But unable to extract the zip file.
It given 'Blank file' error.
It can be seen even in the demo, when a certain amount of files are appended in the zip a error opening zipfile in zipOpen3
error appears without explanation.
So I needed to use this module, despite certain shortcomings, because it was the only one I found that supports passwords, and we're dealing with exporting personal information in our app. I note that when appending a file, you're supposed to provide a String, Buffer or Uint8Array as the data argument. However, when debugging, I noticed the following inconsistent behaviour when given edge-case or incorrect arguments:
data
is given as one of undefined
, null
, 0
or 1
(numbers), false
or true
(booleans), or {}
(empty object), it throws an exception right away (expected, those don't make sense as a file defined as an array of bytes)''
(empty string), or []
(empty array), doesn't throw an exception (expected, those make sense to me as representing an empty file)[{}, {}, {}]
(array of empty objects), [{a:1,b:2},{a:11,b:22},{a:111,b:222}]
(array of objects with consistent properties), [{a:1,b:2},{c:11,d:22},{e:111,f:222}]
(array of objects with inconsistent properties), doesn't throw an exception (unexpected, they don't make sense as a file defined as an array of bytes)7z l test.zip
):
7z x test.zip
):
I am using this library with Angular 8 when I install it with NPM and used it with var Minizip = require('minizip-asm.js'); its throwing error :
minizip-asm.min.js:18 Uncaught TypeError: Cannot read property 'TYPED_ARRAY_SUPPORT' of undefined
at Object. (minizip-asm.min.js:18)
at Object. (minizip-asm.min.js:18)
at r (minizip-asm.min.js:1)
at Object. (minizip-asm.min.js:17)
at r (minizip-asm.min.js:1)
at Object. (minizip-asm.min.js:14)
at Object. (minizip-asm.min.js:14)
at r (minizip-asm.min.js:1)
at minizip-asm.min.js:1
at minizip-asm.min.js:1
When i try extract zip file which contains txt files
This error is displayed:
Error: Can't get buffer length
my code
` let mz=new minizip(Buffer.from(fs.readFileSync(filename)))
let buf=mz.extract('report.txt', { password: "abc"})
console.log(buf,'response')`
Hello:
Is there a method to remove an existing file from the minizip object? or at least update it?
Thanks
Just testing out the implementation. My file is about 4K and when created a zip file using WinRar, its size becomes 1.7KB. However, with minizip, when I create the zip files, its size becomes 64KB, 16 times larger than the original file. Can you please check?
Hi,
I'm working with Angular (typescript).
How I can create zip with password passing Blob object or string?
I don't want to use files on local paths.
Thanks
Do you have full minizip-asm.js
with full source code on native JavaScript, not minified
minizip-asm.min.js
.
I want to add unicode supporting for filenames, but minified file is very-very not readable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.