Anybody know if it’s possible to take a response f...
# suitescript
j
Anybody know if it’s possible to take a response from API call that sends a file as
application/binary
and convert it to base64 text to save it to the file cabinet in SuiteScript? The traditional javascript methods like
btoa()
arent’ available serverside.
b
generally you are doomed if this is suitescript serverside
netsuite will encode it as a string and that is wrong for binary data
s
I had to do the reverse - sending an octect stream to an API so ended up writing an Azure Functions middleman to translate NetSuite's base64.
j
I am actually thinking of going the same route with an azure function for my use case. One interesting thing I found in my research was that if the content-type of the response is
application/octet-stream
then NetSuite will auto convert the binary data into base64 text. Any other content-type, like
application/binary
and it won’t auto convert, just treats it like text.