Have a look at: https://stackoverflow.com/questions/246801/how-can-you-encode-a-string-to-base64-in-javascript to get an idea for the javascript base64 encoding/decoding
[Update]
For image to base64 see: https://stackoverflow.com/questions/6150289/how-can-i-convert-an-image-into-base64-string-using-javascript
Hi Vignes,
The JavaScript engine in the Native React client is JavaScript Core https://reactnative.dev/docs/javascript-environment (a Fun fact, when debugging the environment is the v8 of your browser, this explains way it might work while debugging but on on the device)
This JsCore does not support the same function as v8 on the web. So there is no easy way to convert a file to base 64 in both directions.
Google around and you might get somewhere. But it always requires an additional module.... https://stackoverflow.com/questions/34908009/react-native-convert-image-url-to-base64-string
So if you got one working let us know! I would love to see a simpler solution.
Cheers,
Andries
+1
Vignesh S, did you figure it out? I have the same problem. :\
const fileUrl = mx.data.getDocumentUrl(file.getGuid(), file.get("changedDate"));
let base64 = await NativeModules.NativeFsModule.readAsDataURL(fileUrl);
Worked for me if you have your document as MxObejct.