Skip to content

Commit 4c84796

Browse files
authored
Create Convert image into base63 encoded string.js
1 parent 502f3c7 commit 4c84796

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var BigEncoder64 = Class.create();
2+
3+
BigEncoder64.prototype = {
4+
initialize: function() {
5+
},
6+
// This script will help to convert the image into base64 encoded string.
7+
GetBase64EncodedString: function(attachment_sys_id) {
8+
var StringUtil = new GlideStringUtil();
9+
var gsis = GlideSysAttachmentInputStream(attachment_sys_id); // pass the attahment sys_id
10+
var baos = new Packages.java.io.ByteArrayOutputStream();
11+
gsis.writeTo(baos);
12+
baos.close();
13+
var base64Data = StringUtil.base64Encode(baos.toByteArray());
14+
return base64Data; // return the base64 encoded string.
15+
},
16+
17+
type: 'BigEncoder64'
18+
};

0 commit comments

Comments
 (0)