Actually I trying to upload large text and pdf files. I want to compress file chunks in browser only. So i can encrypt and send these lite chunk through ajax smoothly without hanging browser. I am seeking help related to file chunk compression. And at server side easily can decompress using java library. Can anyone suggest me best way to do it ? It should be in client side and inside browser(IE11,Google Chrome).
Asked
Active
Viewed 3,663 times
4
-
2why is here `java` tag? – Andrew Tobilko Mar 16 '16 at 17:35
-
I think Amazon sends all its images as zip files, to save space and increase upload times, as is evident, but I'm not sure about the exact compression type - might be bzip or gzip. – Arif Burhan Mar 16 '16 at 17:37
-
If anyway we can call java utility inside javascript so. – Jeet Mar 16 '16 at 17:37
-
http://danml.com/js/compression.js has deflate() and inflate() which works pretty well – dandavis Mar 16 '16 at 17:42
-
@ArifBurhan okay but if you have some idea can you tell me which library i can you use my case. – Jeet Mar 16 '16 at 17:43
-
yeah, the core was written in 1999, and now it's easier than ever to send binary without `btoa()` support – dandavis Mar 16 '16 at 17:57
-
@dandavis okay I will try it out. – Jeet Mar 16 '16 at 18:06
-
if you will `inflate()` with java, mind the UTF encoding of JS strings... – dandavis Mar 16 '16 at 18:11
-
@dandavis sure I will do. One more thing , where can i get document for this library(danml.com/js/compression.js ) then it will be easy for me. – Jeet Mar 16 '16 at 18:14
-
afaik, there is none. `deflate(strContent)` returns `strCompressed`, `inflate()` does the opposite. `inflate(deflate("hello"))=="hello";` – dandavis Mar 16 '16 at 18:32
-
@dandavis okay , thanks – Jeet Mar 16 '16 at 18:35
2 Answers
5
Gzip is a popular method for compressing data before sending it over the web.
There are many javascript libraries, such as https://github.com/beatgammit/gzip-js which will compress a string/byte array for you.
Java has Gzip functionality built-in through java.util.zip.GZIPInputStream;
; a simple google search will make it easy to learn how to use it.

Ameo
- 2,307
- 5
- 21
- 33
-
thanks but I have to use in production so i have some restrictions on GPL license so. If you can help me with client side with other library please. I m okay with server side GZIP. – Jeet Mar 16 '16 at 17:53
0
There are several JS libs that can help you with that, if the zip
format is acceptable. JSZip is one of the most well known ones.

OliverRadini
- 6,238
- 1
- 21
- 46

lucasnadalutti
- 5,818
- 1
- 28
- 48
-
thanks but It's under gpl so I can't use it. If any other suggestions please let me know. – Jeet Mar 16 '16 at 18:01