Compress Data in JavaScript and send it to Flask Server

506 Views Asked by At

So my team has made a small tool to perform Image Annotation and Labeling. And we were trying to optimize our code. We were able to compress data from the server, but we have been trying to perform compression on data that is being sent from client to server. What data you may ask, its just text file around 2 - 3mb. Is there any way we can perform compression? We are using JavaScirpt and want to send to FLASK.

This is the first question i am posting on here :)

1

There are 1 best solutions below

0
yavuzkavus On

You can try with this lib: Paco-zlib

var binaryString = pako.deflate("2-3mb text content", { to: 'string' });
// Here you can do base64 encode, make xhr requests and so on.

But at server side, responding page will receive compressed data. You shoud decompress it using something like zlib.decompress(compressedData)