Hello! I cannot quite figure out how to upload bin...
# suitescript
j
Hello! I cannot quite figure out how to upload binary files using the "https" library. I'm trying to upload files to OneDrive via it's API, but it only supports binary streams, not base64. I have tried passing https.put a Uint8Array but that doesn't seem to work, so I'm trying to pass the data as a string. I almost have it working, but bytes > 0x7f get encoded with utf-8 and the bytes get messed up. Does anyone know how to go about this correctly? Thanks!
s
I had to do this recently and ended up using an Azure function to be a lightweight proxy to translate the base64 to RAW and forwarding on to MS Graph API
it is frustrating but
base64
looks to be the only option for binary data in SuiteScript.
j
Oh interesting, haven't worked with Azure functions before. I'll look into setting one up, thank you!
s
you can do the same with Google or Amazon's similar offerings
since node has built in support for decoding that base64 the guts of the function is only like one line of code.
u
yup. I also had that frustrations on SuiteScript only supporting base64 forcing me to use AWS Lambda for on my case with the one that I worked on before