Expo readAsStringAsync in FileSystem crashes with EncodingType as Base64


  1. SDK Version: 36
  2. Platforms(Android/iOS/web/all): iOS and Android
  3. My device: iPhone 6S Plus


I’m trying to record a video and upload to Azure Blob Storage. This is pretty straight forward given the time I had spent to configure things and getting things right. In order to upload I need to be able to read the recorded video file as base64. I have done this in a try catch statement. I have successfully uploaded files which are ~45mb in file size. However when I read a file which is about 5 minutes in duration and file size over 50mb I get an error as follows.

Unrecognized event: [[154,154,154,154,154,154,130],[4,4,4,4,4,0,1],[[“didReceiveNetworkResponse”],[“didReceiveNetworkData”],[“didReceiveNetworkIncrementalData”],[“didReceiveNetworkDataProgress”],[“didCompleteNetworkResponse”],[3354,2000,1588331272809,false]],20999]

The code i have in place is

const fileUri = ‘file:///var/mobile/Containers/Data/Application/path-to-vide/demo_xyz.mov’;

const options = {
encoding: FileSystem.EncodingType.Base64
const fileBase64 = await FileSystem.readAsStringAsync(fileUri, options);

How do i solve this issue? Is there an alternate expo compatible code I can use to convert a file to base64?

I am also facing the same issue with expo. Any solution for this?

Files must be placed in FileSystem.documentDirectory to read / write

//  to decode download and read the base64 file content as base64 string
const fileContentBase64 = await FileSystem.readAsStringAsync(
          encoding: FileSystem.EncodingType.UTF8,

// Decode base64 content string to binary and write to usable file
      await FileSystem.writeAsStringAsync(destinationUri, fileContentBase64, {
        encoding: FileSystem.EncodingType.Base64,

Thank you @adcr for your response. So the problem here is that we are unable to convert to base64 using readAsStringAsync for larger files. That said, why have you mentioned UTF8 as an encoding type when reading the file?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.