FileReader.readAsDataURL在React Native 0.57中不起作用

时间:2019-08-05 11:08:28

标签: react-native filereader

我需要将从获取请求中接收到的图像解析为base64字符串。当我使用RN 0.55.4时,我的代码可以正常工作,但是升级到RN0.57后,它不再起作用。 升级后,我已经记录了base64字符串,并且得到了:

IMAGE64 data:application/octet-stream;base64,77+977+977+977+9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...(a bunch of "A"s)

下面是代码

    const fileReaderInstance = new FileReader()
       fileReaderInstance.readAsDataURL(response)
        fileReaderInstance.onload = () => {
       //result is always something like -- data:application/octet-
     //stream;base64,77+9UE5HDQoaCgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//`enter code here`AAAAAAAAAAA... (thousands of As)
             console.log(fileReaderInstance.result)

   }

0 个答案:

没有答案