Hi all i'm trying to decode a base64 string into B...
# suitescript
s
Hi all i'm trying to decode a base64 string into Blob in a map reduce script. but it is giving error for few functions as not defined(e.g. atob is not defined or Blob is not defined). Below is code i'm using. Any help would be appreciated! function base64ToBlob(base64, contentType = "", sliceSize = 512) { const byteCharacters = atob(base64.split(",")[1]); const byteArrays = []; for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { const slice = byteCharacters.slice( offset, offset + sliceSize); const byteNumbers = new Array(slice.length); for (let i = 0; i < slice.length; i++) { byteNumbers[i] = slice.charCodeAt(i); } const byteArray = new Uint8Array(byteNumbers); byteArrays.push(byteArray); } const blob = new Blob(wxport, { type: contentType }); return blob; }
b
doomed task for serverside suitescript, Blobs are for browsers/Node
suitescript represents files as base64 strings, which is fairly nonstandard and annoying to manipulate
s
Hi @battk Is there any solution to this issue or any js lib we can use?
b
no, find an alternative method in whatever library you are trying to use