0

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 :)

  • Afaik there is no standard way to do this. Maybe you can try zip the file in client side using jszip https://stuk.github.io/jszip/, upload it, and unzip it in the backend using `zipfile` https://docs.python.org/3/library/zipfile.html – Yohanes Gultom May 27 '19 at 12:24

1 Answers1

0

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)

yavuzkavus
  • 1,268
  • 11
  • 17