Skip to main content
Version: 1.20.1

SimpleImage

This class provides methods to manage the images from the Image (sys_image) table.

getErrors()


Use this method to receive error messages.

Return:

TypeDescription
Array of StringsThis method returns an array of strings that contains error messages.

Example:

getErrors()
const record = new SimpleImage();
record.getImageUrlById('163273889311202251')
ss.info(record.getErrors());

//Info: ["Image with sys_id \"163273889311202251\" not found."]

getImageUrlById(imageId)


Use this method to get the URL of the specified image at the storage.

Parameter(s):

NameTypeMandatoryDefault value
imageIdStringYN

Return:

TypeDescription
StringThis method returns a URL of the image.

Example:

getImageUrlById()
const image = new SimpleImage();
const imageUrl = image.getImageUrlById('161443499412945709');
ss.info(imageUrl);
// Info: https://your-instance.simpleone.ru:9000/cover/d/27/tfsnhvtowmw07zxhti5c46brtfyf?...

readImageBase64(imageId)


Use this method to receive a base64-encoded image.

Parameter(s):

NameTypeMandatoryDefault value
imageIdStringYN

Return:

TypeDescription
StringThis method returns a base64-encoded image.

Example:

readImageBase64()
const image = new SimpleImage();
const imageBase64 = image.readImageBase64('161443499412945709');
ss.info(imageBase64.slice(0, 10));
// Info: R0lGODlh/g

writeImageBase64(fileName, base64, contentType, imageColumnId)


Use this method to create a record with a base64-encoded image in the Image (sys_image) table. To add the image to a particular column, specify the column in the imageColumnId parameter.

Parameter(s):

NameTypeMandatoryDefault value
fileNameStringYN
base64StringYN
contentTypeStringYN
imageColumnIdStringYN

Return:

TypeDescription
StringThis method returns the image record ID.

Example:

writeImageBase64()
const image = new SimpleImage();
const base64 = 'iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAABHNCSVQICAgIfAhkiAAABYFJREFUeJzt3SGQVVUcwOGLQyDSoGkDGyRpYnJIaFpIQDLiNrdh2jE5NE1Ic5smJaHRJLSlSdNGpGl2TOfIu+/xft+X75lzF977zQnvP+fMwt64uSx/b/sdtunHZTmz7Xd427yz7RcAtkcAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIMzwxErWGNQ5+fD+preY9+3g85+Nb3Hw68PhNfUBIicACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACDu77Rd4G80M9qwxqPPTn682vseyLMv7X5wOr3lvuTa24MlXw3ss58aHgeqcACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACAsfSnCssz9rv/upTvD+9y4eH7o+bV+1//pi8er7LNn9uZ74wQAYQIAYQIAYQIAYQIAYQIAYQIAYQIAYQIAYQIAYQIAYQIAYXsz1LAs6w32rMGQzt7Zye+aEwCECQCECQCECQCECQCECQCECQCECQCECQCECQCECQCECQCEnd32C2zbjZO7w2vOXfnozb/IG/D6/mfDa849/HYn95ncYycHbnaZEwCECQCECQCECQCECQCECQCECQCECQCECQCECQCECQCECQCE7ezwxMwtPyfPng7v8/XxreE1h0ffD68ZHSCaGYZZ7o3/LTODTa8n/p2H//6V/i9nHJ38tbPfm1FOABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABC2XzcDPRof0tlVUzf2TAwDzQzdzFhjn5khrTm3hgfVdnWAyAkAwgQAwgQAwgQAwgQAwgQAwgQAwgQAwgQAwgQAwgQAwvZqFmDq9/MzF3CsYK3f6E9dDLKj/2aMcwKAMAGAMAGAMAGAMAGAMAGAMAGAMAGAMAGAMAGAMAGAMAGAsJ28rOB/GL6wYcYqwzATl3zMDPYwZW++N04AECYAECYAECYAECYAECYAECYAECYAECYAECYAECYAECYAELY3Qw3/w/AA0fHBhU28x78cXvxk43vMmrmBaYelvwNOABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABCWHoSYdXNigOjupTtDz59e+Xl0i532zennQ8+/fH7ks7kCJwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIyw9crDHYM+PGxfPDaz6+fnkDb/Jf129f3fge3x08HV5jgGicEwCECQCECQCECQCECQCECQCECQCECQCECQCECQCECQCEnd32C7yN1ri043Rq1YPhFU+O7k3tNOr4j2dDz7/47XB4j0sfjM911OcHnAAgTAAgTAAgTAAgTAAgTAAgTAAgTAAgTAAgTAAgTAAgTAAgLD8MdO3gwvCaw8cvN/Amb8CddycWrTMMxG5yAoAwAYAwAYAwAYAwAYAwAYAwAYAwAYAwAYAwAYAwAYAwAYCw/DDQrvp6YrDn58sPxtccPxpeM+P67atDz4/eJMQcJwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIEwAIMwzEsD9+eDW85pfl943v8fL50ZnhRXFOABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABBmeGLC8cGFv7f9Dm/K0clfw2uODy6ssY/P5gqcACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACDM763nDM8CzPx+fg2HX94aXnPu8sPhNa9P7298j8XneZgTAIQJAIQJAIQJAIQJAIQJAIQJAIQJAIQJAIQJAIQJAIQJAIQZnpizNxeD7Bmf50FOABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABAmABD2D4/fmKms6poKAAAAAElFTkSuQmCC';
const imageId = image.writeImageBase64('mario.png', base64, 'image/png', '156819163902483433'); // photo_id column Id
const myProfile = ss.getUser();
myProfile.photo_id = imageId;
ss.info(myProfile.photo_id);
// myProfile.update();
// Info: 161443574018665376