I am trying to convert an image to base 64 and sto...
# suitescript
k
I am trying to convert an image to base 64 and store the value in a field. What script do you recommend I do this on? I tried to use document.createElement on a userEvent script but I get the error "document is not defined [at Object.beforeSubmit (/SuiteScripts/CLCIntegration/CLCButtonUEScript.js15926)]" Should I do this on a client script? Create a custom function?
c
You only have access to browser APIs and the DOM in client script
Are you trying to store the base64 string in a field on the Netsuite record? Are you making sure the field max length will accommodate the length of that string?
b
sounds misguided from the beginning
if your image is not in base64 already, you are unlikely to be able to convert it base64 in the first place
k
I am trying to submit the image as a byte array.
I was told to do this in order to submit the image properly as a json object
b
start at the beginning
where is the image coming from and how are you getting it
k
I am getting the image from a url that is on the record. I must take that url and convert it into a byte array.
I can't find any fucntions online that takes a url and converts it into a byte array that returns a value.
b
bad searching
you have a url, which probably means you need to do a https get on that url to get the image
k
https module?
b
if you are doing this serverside, then yes, N/https is the primary option