Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This server class provides methods that allow operating with attachments.

SimpleAttachment()


Instantiates a new empty SimpleAttachment object.


Code Block
languagejs
themeEclipse
titleSimpleAttachment
linenumberstrue
let attach = new SimpleAttachment();

base64Decode(data)

This method returns an ASCII string decoded from the base64 string specified.

NameTypeMandatoryDefault ValuedataStringYN

Return:

TypeDescriptionStringThe decoded string.

Example:

Code Block
languagejs
themeEclipse
titlebase64Decode
linenumberstrue

base64Encode(data)

This method returns a Base64 string from the string specified.

NameTypeMandatoryDefault ValuedataStringYN

Return:

TypeDescriptionStringThe encoded Base64 string.

Example:

Code Block
languagejs
themeEclipse
titlebase64Decode
linenumberstrue

copy(sourceTable, sourceID, targetTable, targetID)

This method copies attachments from the source record to the target record.

Parameter(s):

NameTypeMandatoryDefault Value
sourceTableStringYN
sourceIDStringYN
targetTableStringYN
targetIDStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlecopy
let attach = new SimpleAttachment();
attach.copy('user', '155964310500000059', 'sys_script', '155964310500000051');


deleteAttachment(attachmentID)

This method deletes the specified attachment.


Parameter(s):

NameTypeMandatoryDefault Value
attachmentIDStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titledeleteAttachment
let attach = new SimpleAttachment();
attach.deleteAttachment('157052637119478714');

getCloudStorageUrl(attachmentId)

This method allows to get the URL of the specified attachment at the cloud storage.

Name
TypeMandatoryDefault ValueattachmentIdstringYN

Return:

TypeDescriptionStringThis method returns the attachment URL in the cloud storage.


Example:

Code Block
languagejs
themeEclipse
titlegetCloudStorageUrl
linenumberstrue

getContent(sysAttachment)

This method gets attachment content as a string.

NameTypeMandatoryDefault Value
sysAttachmentSimpleRecordYN


Return:

TypeDescription
StringThe attachment content as a string.


Example)

Code Block
languagejs
themeEclipse
titlegetContent
let attach = new SimpleAttachment();
let content = attach.getContent('157052637119478714');


rename(attachmentId, fileName)

This method renames the specified attachment.


Parameter(s):

NameTypeMandatoryDefault Value
attachmentIdStringYN
fileNameStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlerename
let attach = new SimpleAttachment();
attach.rename('157052637119478714', 'new_name_1.png');

write(record, fileName, contentType, content)

This method inserts the attachment to the record specified.

NameTypeMandatoryDefault Value
recordSimpleRecordYN
filenameStringYN
contentTypeStringYN
contentStringYN


Return

TypeDescription
StringThe attachment's sys ID.

Example:

Code Block
languagejs
themeEclipse
titlewrite
let attach = new SimpleAttachment();
let record = attach.write('157052637119478714', 'readme.md', 'text/markdown', '# h1 title');

writeBase64(documentId, fileName, base64, contentType)

This method inserts the attachment to the record specified using Base64 encoding.

NameTypeMandatoryDefault ValuedocumentIDStringYNfileNameStringYNbase64StringYNcontentTypeStringYN

Return

TypeDescriptionString or NULLThe attachment's sys ID; in case of error; returns NULL.

Example:

true
Code Block
languagejs
themeEclipse
titlewriteBase64
linenumbers



Table of Contents
absoluteUrltrue
classfixedPosition