GLIDEZIPUTIL

rohanhd
Kilo Contributor

Hi All,

I need to un gzip the attachment which has an image. I have got the attachment from the sys_attachment_doc table in 4k chunks. Ordered by position, base64 decoded the chunks and added them together to get a gzip version. I can also do this via the attachment API. Again I will get gzip version.

To unzip I wanted to use GlideZIPUTIL ZIP_UNZIPPING function. when I explore it using following

or (var i in GlideZipUtil) {

      gs.print(i);

}

I get

*** Script: addEntry

*** Script: CHARSET

*** Script: UTF_8

*** Script: _8859

*** Script: _8859_1

*** Script: ZIP_UNZIPPING

*** Script: WINDOWS_1252

*** Script: ZIP_WRITTEN

*** Script: ISO_8859_1

*** Script: ZIP_ZIPPING

But when I try accessing ZIP_UNZIPPING it gives me error

Attempted script access to inaccessible member denied - com.glide.util.ZipUtil:ZIP_UNZIPPING:

Evaluator: java.lang.SecurityException: Illegal access to field ZIP_UNZIPPING in class com.glide.util.ZipUtil

  Caused by error in script at line 21

  18: }

  19:

  20: this.ZipUtil = new GlideZipUtil();

==> 21: var img = ZipUtil.ZIP_UNZIPPING(base); //won't let me access ZIP_UNZIPPING

  22:

  23: quote = quote + "<tr><td >"+ img +"</td></tr>" //trying to print image

  24:

17 REPLIES 17

rohanhd
Kilo Contributor

my apologies my documenting method seemed incorrect hence I have used:



var s = new GlideZipUtil();


for(var member in s){


gs.print(member);


}



this gave me


*** Script: getClass


*** Script: wait


*** Script: zipDir


*** Script: notifyAll


*** Script: lastUnzippedFilePath


*** Script: unzip


*** Script: validZip


*** Script: notify


*** Script: isValidZip


*** Script: setIncludeSubdirectories


*** Script: includeSubdirectories


*** Script: hashCode


*** Script: getEntry


*** Script: class


*** Script: addListener


*** Script: zip


*** Script: setFileTypes


*** Script: removeListener


*** Script: fileTypes


*** Script: setStartPath


*** Script: getLastUnzippedFilePath


*** Script: entry


*** Script: startPath


*** Script: equals


*** Script: toString



I see the unzip class but can't call it


Actually class GlideZipUtil is deprecated and should not be used anymore. The methods you see there are not whitelisted so you can't call them without getting a SecurityException.


Hi Sergiu the reason is that I want to extract one image attachment and put into word document. Hence I did the following:



1. Got the 4k attachment chunks from sys_attachment_doc


2. base64 decoded them


3. concatenated them as per position


4. but these will be gzip so how to unzip on server side



even if I use Attachment API and get the attachment it will still be in GZIP.



Any help would be good.


@rohanhd 

How did you solve #4?

I have a situation where I need to unzip the contents from attachment_doc table

var strEncodedString1 = 'H4sIAAAAAAAAAA==';
var strEncodedString2 = 'c02f9YhJlJGRkUXA9aIzv02JX0yX7jFb3lM/uAA/lprDGwAAAA==';
var objStringUtil = new GlideStringUtil();
var bytes1 = objStringUtil.base64Decode(strEncodedString1);
var bytes2 = objStringUtil.base64Decode(strEncodedString2);


gs.log(bytes1 + bytes2); //This gives a zip string. I would have to decompress it to get the contents as text 'ABCD'

I am stuck at the decompressing part.

 

 

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022