gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.4k stars 510 forks source link

We need zip js for Angular 11 #474

Closed DJ-991 closed 8 months ago

DJ-991 commented 8 months ago

How can we use zip.js in Angular11? I need to encrypt zip having pdf. Please suggest, after npm install how can we use zip.js in angular framework? We have blob for the PDF.

gildas-lormeau commented 8 months ago

What should be particular to Angular 11?

DJ-991 commented 8 months ago

Just in angular how can we implement zip.js

gildas-lormeau commented 8 months ago

Like in any other JavaScript/TypeScript project?

DJ-991 commented 8 months ago

This is angular project with typescript, we need to encrypt the zip having pdf blob. Can we do this with zip.js?

Ask- whenever user open that downloaded zip, it should ask for the password.

gildas-lormeau commented 8 months ago

Yes, it is probably possible to implement this. What's blocking you?

DJ-991 commented 8 months ago

image

is this code is fine for encryption and zip that pdf blob? blob we are getting from API

DJ-991 commented 8 months ago

PFA - by running: $ npm install @zip.js/zip.js

and importing the libary as an ECMAScript module: import * as zip from "@zip.js/zip.js";

using like this : useCompressionStream is giving error in code image

gildas-lormeau commented 8 months ago

useCompressionStream is an option passed to zip.configure(). See here for an example of code using encryption: https://github.com/gildas-lormeau/zip.js/blob/master/tests/all/test-crypto.js.

DJ-991 commented 8 months ago

https://github.com/gildas-lormeau/zip.js/blob/master/tests/all/test-crypto.js should we use that code(test-crypto.js) for encryption in our typescript code and for zipping ? @gildas-lormeau

gildas-lormeau commented 8 months ago

This is a code example that shows how to write a zip file with an AES password so I assume it's similar to what you want to do.

DJ-991 commented 8 months ago

Will try this code hope this will work. @gildas-lormeau

gildas-lormeau commented 8 months ago

You'll probably have to follow these instructions as well: https://github.com/gildas-lormeau/zip.js/discussions/229

DJ-991 commented 8 months ago

image getting this error after config

here it is: 1: create file inside src - image

2: angular.json "serve" config image

3: angular.json "builder" and "options" image

4: package.json image

My angular version is Angular 11. so i installed npm install -D @angular-builders/custom-webpack@11.1.1

gildas-lormeau commented 8 months ago

It looks like the ES version in your project is too old. Here is the fix of a similar issue in Angular CLI:

DJ-991 commented 8 months ago

in which file we need to change tsconfig.json or package.json ? not getting image

gildas-lormeau commented 8 months ago

I'm sorry but I don't know because I don't use Angular.