From 4c847964840baeed145ed69203ba5820457e6176 Mon Sep 17 00:00:00 2001 From: Abhishek Thakur <146176327+at8807602@users.noreply.github.com> Date: Wed, 2 Oct 2024 04:54:11 -0700 Subject: [PATCH 1/2] Create Convert image into base63 encoded string.js --- ...Convert image into base63 encoded string.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Script Includes/Convert image into base64/Convert image into base63 encoded string.js diff --git a/Script Includes/Convert image into base64/Convert image into base63 encoded string.js b/Script Includes/Convert image into base64/Convert image into base63 encoded string.js new file mode 100644 index 0000000000..2bc1f848d6 --- /dev/null +++ b/Script Includes/Convert image into base64/Convert image into base63 encoded string.js @@ -0,0 +1,18 @@ +var BigEncoder64 = Class.create(); + +BigEncoder64.prototype = { + initialize: function() { + }, + // This script will help to convert the image into base64 encoded string. + GetBase64EncodedString: function(attachment_sys_id) { + var StringUtil = new GlideStringUtil(); + var gsis = GlideSysAttachmentInputStream(attachment_sys_id); // pass the attahment sys_id + var baos = new Packages.java.io.ByteArrayOutputStream(); + gsis.writeTo(baos); + baos.close(); + var base64Data = StringUtil.base64Encode(baos.toByteArray()); + return base64Data; // return the base64 encoded string. + }, + + type: 'BigEncoder64' +}; From 1abff871980c6cf76c6868e43090503be2671263 Mon Sep 17 00:00:00 2001 From: Abhishek Thakur <146176327+at8807602@users.noreply.github.com> Date: Wed, 2 Oct 2024 04:55:39 -0700 Subject: [PATCH 2/2] Create README.md --- Script Includes/Convert image into base64/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Script Includes/Convert image into base64/README.md diff --git a/Script Includes/Convert image into base64/README.md b/Script Includes/Convert image into base64/README.md new file mode 100644 index 0000000000..059e5c7ecc --- /dev/null +++ b/Script Includes/Convert image into base64/README.md @@ -0,0 +1 @@ +This script include helps to convert the image into base64 encoded string easily. Mainly used during the rest integrations when it comes to the handling the attachment.