Teoman shipahi
Teoman shipahi

Reputation: 23042

How to convert gzip encoded response into base64 string

I have an ajax response receiving as Content-Encoding as gzip.

I would like to convert it into base64 encoded string.

enter image description here

In firefox/firebug Net tab I can open response and see in base64 encoded text.

enter image description here

As you can see below, firebug can convert response into base64 string. I can save this file as abc.zip and unzip successfully. How can I achieve it in JavaScript? (Converting ajax response into base64 string)

enter image description here

Upvotes: 1

Views: 2524

Answers (1)

mti2935
mti2935

Reputation: 12027

You need to decompress the gzip-encoded string first to get the string in uncompressed form, then you can base64 encode the uncompressed string.

See JavaScript implementation of Gzip for info on how to decompress gzip-encoded strings.

Upvotes: 1

Related Questions