1

I got to check this library react-native-fs because I have this task wherein I have to convert a video into base64 string before sending it to our API. I am using the readFile function that's provided by this library to achieve that. But somehow I am not sure why it returns an infinite base64 encoded string.

Here is my code snippet:

    import { RNFS } from 'react-native-fs'

    const callbackFunctionVideo = async (videoData: any) => {
      const videoUri= { 
          uri: videoData.assets[0].uri, 
          fileName: videoData.assets[0].fileName, 
          type: videoData.assets[0].type
      }

      const base64_vid = RNFS.readFile(videoUri.uri, 'base64').then(res=> res).catch(err=>err)

      console.log(base64_vid)    
    }

Then when it logs, it will be an infinite base64 string(I'm not sure if it is looping though).

0 Answers0