GlideStringUtil.base64Encode is not converting large files to base64encode string.

Palle
Tera Contributor

Hi SN community, 

We have a SOAP based integration with a third party system where we will be sending the large attachments >5mb through the webService call to the third party system. I am using GlideStringUtil.base64Encode to convert the attachments to base64encode string, any attachments >5MB are not getting converted to string. 

Is there any other way I can achieve converting large files to base64 encoded string?

Any suggestion/recommendations would be appreciated.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I think for more than 5mb file base64encoded data is difficult to get; try checking below script whether it works; gr is the gliderecord object of sys_attachment table

var StringUtil = new GlideStringUtil();

var gsis = GlideSysAttachmentInputStream(gr.sys_id.toString());

var ba = new Packages.java.io.ByteArrayOutputStream();

gsis.writeTo(ba);

baos.close();

var base64EncodedData = StringUtil.base64Encode(ba.toByteArray());

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Palle
Tera Contributor

I had a problem in the SOAP payload request size if my attachments are bigger than 15MB, basically the payload is getting truncated. 

nicolancl
Tera Contributor

Hi RG, did you find any solution? I got the same issue...

Palle
Tera Contributor

Hi Nicolancl, 

Not at this moment, we restricted the users not to attach more than 15MB on the incident table. 

nicolancl
Tera Contributor

Thank you for answering.

Are there any workaround? Unable to find anywhere. I need to SEND attachments >15mb to MIDServer.

 

 

lasse3
Mega Guru

Just wanted to add, that the maximun attachment size that the system will return a base64 encoding for is controlled by com.glide.attachment.max_get_size property.

If the setting does not exist it will default to maximum 5 MB.

You can change this standard value as per your need. However, as mentioned in the following KB, this may cause some issues.

https://hi.service-now.com/kb_view.do?sysparm_article=KB0683260