Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compress base64 string [closed]

Tags:

c#

base64

unity3d

i'm sending the 5mb base64 string to the backend api from the unity android app. while post and get the app gets slow because of heavy data is incoming. i want to compress the base64 5mb string to lesser size. can anyone help me in finding the solution

i have tried all the solutions like GZipStream and all other, but they are working fine with the normal string but not helping when trying with base64.

can anybody tell how to compress and decompress base64 string.

like image 464
nithish pitla Avatar asked Dec 18 '22 14:12

nithish pitla


1 Answers

Base64 is already encoded in a way which does not suit most compression algorithms - see Why does base64-encoded data compress so poorly? for details.

You will want to compress the original binary data and then base64 the compressed data, or don't bother converting to base64 at all.

Additionally many HTTP clients/servers will automatically compress the stream, so this may be happening already implicitly.

A better question may be why you are sending such a large amount of data in a web request, perhaps you should try to reduce the size instead of attempting to compress it...

like image 53
Milney Avatar answered Dec 24 '22 00:12

Milney