Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
ZIP Support
You can compress multiple attachments or documents into an Apex blob that contains the ZIP archive. You can also specify the data to be extracted from the zip archive, without uncompressing the entire ZIP archive. To optimize compression, you can specify a compression method and compression level.
This example code extracts a JSON translation file from a callout response containing a ZIP archive by getting and extracting the specified entry from the ZIP archive.
1HttpRequest request = new HttpRequest();
2request.setEndpoint('callout:My_Named_Credential/translationService');
3request.setMethod('POST');
4// Set request payload to translate...
5
6HttpResponse response = new Http().send(request);
7Blob translationZip = response.getBodyAsBlob();
8
9ZipReader reader = new ZipReader(translationZip);
10ZipEntry frTranslation = reader.getEntry('translations/fr.json');
11Blob frTranslationData = reader.extractEntry(frTranslation);
12