GlideSysAttachment().getBytes() is not working if size of attachment is more than 5 MB?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 12:55 AM
Hi All,
I am using Helsinki and I am facing same Issue When file size is greater than 5 MB showing as 0 bytes.Debugging this, at the line var binData = sa.getBytes(att), binData.length = 0.In ServiceNow community we see similar post(https://community.servicenow.com/thread/195363) which says getBytes() method has a limit of 5MB I tried solution given in the post(https://community.servicenow.com/thread/195363) but it doesn't work.Can any one help in resolving this.
Below is part of script I use:
function sendAttachment(att,counter) {
gs.log('Export Attachments Script - Send Attachment #'+counter+' - START');
var bool = false;
try {
//Create GlideSysAttachment object
var sa = new GlideSysAttachment();
//Gets the binary data of the passed attachment
var binData = sa.getBytes(att);
//Encodes the binary to base64
var encData = GlideStringUtil.base64Encode(binData);
//Prepares a file name a "TABLE_NAME - (commented)TICKET_SYS_ID - SYS_ID - FILE_NAME"
var file_name = att.table_name + "-" + att.table_sys_id + "-" + att.sys_id + "-" + sanitizeFileName(att.file_name.toString()).trim();
//Calls send Request for binary data and generated file name
sendRequest(encData, file_name);
//If no exception always return true
bool = true;
} catch (Exception) {
gs.log('Failed sending Attachment to due to Exception: '
+ Exception);
}
return bool;
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2019 12:45 AM
Hi Kozhema,
I'm having an issue with base64 conversion from sys_attachment table. I have used below code. It contins limitation as 5 MB and It's not working more than 5 MB file.
Suresh.