GlideSysAttachment - Scoped

The GlideSysAttachment API provides a way to handle attachments.

Content is returned as a string, not as a byte array when getContent() is called.

Content is returned as a GlideScriptableInputStream object when getContentStream() is called. The GlideScriptableInputStream contains the actual bytes not converted into a String.

Scoped GlideSysAttachment - copy(String sourceTable, String sourceID, String targetTable, String targetID)

Copies attachments from the source record to the target record.

Table 1. Parameters
Name Type Description
sourceTable String Name of the table with the attachments to be copied.
sourceID String The source table's sysID.
targetTable String Name of the table to have the attachments added.
targetID String The target table's sysID.
Table 2. Returns
Type Description
String Array of sysIDs of the attachments that were copied.

Scoped GlideSysAttachment - deleteAttachment(String attachmentID)

Deletes the specified attachment.

Table 3. Parameters
Name Type Description
attachmentID String The attachment's sysID.
Table 4. Returns
Type Description
void

Scoped GlideSysAttachment - getContent(GlideRecord sysAttachment)

Returns the attachment content as a string.

Table 5. Parameters
Name Type Description
sysAttachment GlideRecord The attachment record.
Table 6. Returns
Type Description
String The attachment contents as a string. Returns up to 5 MB of data.

Scoped GlideSysAttachment - getContentBase64( GlideRecord sysAttachment)

Returns the attachment content as a string with base64 encoding.

Table 7. Parameters
Name Type Description
sysAttachment GlideRecord The attachment record.
Table 8. Returns
Type Description
String The attachment contents as a string with base64 encoding. Returns up to 5 MB of data.

Scoped GlideSysAttachment - getContentStream( String sysID)

Returns a GlideScriptableInputStream object given the sysID of an attachment.

Table 9. Parameters
Name Type Description
sysID String The attachment sysID.
Table 10. Returns
Type Description
GlideScriptableInputStream A stream that contains the attachment content.

Scoped GlideSysAttachment - GlideSysAttachment()

Creates an instance of the GlideSysAttachment class.

Table 11. Parameters
Name Type Description
None

Scoped GlideSysAttachment - write(GlideRecord record, String fileName, String contentType, String content)

Inserts an attachment for the specified record.

Table 12. Parameters
Name Type Description
record GlideRecord The record to which the attachment is to be attached.
fileName String The attachment's file name.
contentType String The attachment's content type.
content String The attachment content.
Table 13. Returns
Type Description
String The attachment's sysID. Returns null if the attachment was not added.

Scoped GlideSysAttachment - writeBase64( GlideRecord gr, String fileName, String contentType, String content_base64Encoded)

Inserts an attachment for the specified record using base64 encoded content.

Table 14. Parameters
Name Type Description
gr GlideRecord The record to which the attachment is to be attached.
fileName String The attachment's file name.
contentType String The attachment's content type.
content String The attachment content in base64 format.
Table 15. Returns
Type Description
String The sysID of the attachment created.

Scoped GlideSysAttachment - writeContentStream(GlideRecord gr, String fileName, String contentType, GlideScriptableInputStream inputStream)

Inserts an attachment using the input stream.

Table 16. Parameters
Name Type Description
gr GlideRecord The record to which the attachment is to be attached.
fileName String The attachment's file name.
contentType String The attachment's content type.
content GlideScriptableInputStream The attachment content.
Table 17. Returns
Type Description
String The sysID of the attachment created.