Unhandled promise rejection: TypeError: Network request failed - Converting Base64 (video/mp4) to Blob in React Native / Expo

Unhandled promise rejection: TypeError: Network request failed - Converting Base64 (video/mp4) to Blob in React Native / Expo

我正在尝试从我的 phone 中获取一个文件以将其转换为 javascript 文件对象,但为此我首先需要它是一个 blob。到目前为止,这是我的代码:

import * as FS from 'expo-file-system';

let base64 = await FS.readAsStringAsync('file:///storage/emulated/0/DCIM/b914bf57-4899-45d1-a020-fc2b274b4640.mp4', {encoding: FS.EncodingType.Base64});
let base64Response = await fetch(`data:video/mp4;base64,${base64}`);
let blob = await base64Response.blob();
let file = new File([blob], "video.mp4", {type: "video/mp4"});

我怎样才能完成这项工作,或者有更简单的方法吗?我找不到任何适合我的工作示例。在第一个 Fetch() 行引发异常。

通过使用 DocumentPicker 找到了解决方案,这是我的代码:

const { type, uri } = await DocumentPicker.getDocumentAsync({
            copyToCacheDirectory: false,
            type: 'video/mp4',
          });
      
if (type === 'cancel') {
  return;
}
              
const fetchResponse = await fetch(uri);    
const blob = await fetchResponse.blob();  
file = new File([blob], "video.mp4", {type: "video/mp4"});