function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suman GiriSuman Giri 

How to decode an gzip PDF attachment in HTTPResponse

hi,

 

We invoke a REST service to download a PDF from external system, and the Response Headers we get:

 

Date: Wed, 16 May 2012 09:37:02 GMT
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Disposition: attachment; filename="XYZ.pdf"
Server: Apache-Coyote/1.1
Vary: Accept-Encoding
Content-Type:application/pdf

 

What I understand from the above headers is that I could see that the "Content-Encoding" is set as gzip, so instead of the PDF as an attachment, we would get the encoded form of data, which needs to be decoded or unzip in my case and then read the attachment to display the PDF. Is my understanding correct ?

Let me know if there is a way to get this done in Apex HTTPResponse processing ?


Also is there a limit on the size of the file that can be retrieved using a service callout ?
Appreciate any pointers.
Thanks,
Suman