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

I used another method, using the attachment API I saved to the db_image and then displayed that image with the documents. Not very happy though due to the additional REST calls which seem redundant.


austinbuono
ServiceNow Employee
ServiceNow Employee

Would you share?  I have been struggling to unzip an attachment with no luck.  Any help would be greatly appreciated. Thanks! 

Depends why you want to do it. If your attachment only has text you don't need to gUnzip. You can still getbytes or use other sysAttachment methods , toString it since Snow uses RHINO and you are in javascript. That should get you the text.


If you elaborate more on the scenario would be good.

 

 

austinbuono
ServiceNow Employee
ServiceNow Employee

My customer is currently receiving a zip attachment via an inbound email which contains a single excel file.  I am currently tasked with unzipping this attachment and extracting the excel file and transform the data into a custom table for reporting purposes.

Let me know if you need more information. 

Thanks!  

If you look at data sources under system import sets there is a zipped option. It means that the transform maps can use a data source that has a zipped csv or excel file

You could POC by just attaching the zip to datasource and then transform to see how it works.

If that's fine then use the sys attachment copy function and copy from the record to the data source then run the transform map.