Fai*_*mad 0 video base64 react-native
我正在通过 React Native 中的 ImagePicker 从移动本地存储获取视频,现在我想将此视频转换为 Base64 但无法执行此操作。
实现的代码是:
ImagePicker.launchImageLibrary(
  { mediaType: 'video', includeBase64: true },
  (response) => {
    try {
      RNFetchBlob.fs
        .stat(response.assets[0].uri)
        .then((res) => {
          //"res.path" will give me original path of video.
        })
        .catch((err) => {});
    } catch (Excepstion) {}
  }
);
小智 5
查看react-native-fs包。并使用它,例如:
import RNFS from 'react-native-fs';
...
// readFile(filepath: string, encoding?: string)
RNFS.readFile(filePath, 'base64').then(res => {
    ...
})
.catch(err => {
    ...
    console.log(err.message, err.code);
    ...
});
希望这对你有用。
| 归档时间: | 
 | 
| 查看次数: | 3727 次 | 
| 最近记录: |