【问题标题】:How can I convert a base64 url to an image(png/jpg) file, in React-Native?如何在 React-Native 中将 base64 url​​ 转换为图像(png/jpg)文件?
【发布时间】:2021-01-07 06:28:24
【问题描述】:

我想将 base64 URL 转换为 react-native 中的图像文件。是否有一个包或一种简单的方法来实现这一点?

【问题讨论】:

标签: javascript reactjs image react-native base64


【解决方案1】:

您可以尝试像这样使用react-native-fs

import RNFS from 'react-native-fs';

const imageDate = '<some base64 data>';
const imagePath = `${RNFS.TemporaryDirectoryPath}image.jpg`;

RNFS.writeFile(imagePath, imageData, 'base64')
    .then(() => console.log('Image converted to jpg and saved at ' + imagePath));

【讨论】:

  • 感谢您的建议。但是它转换成的,和base64 pathName没有什么区别
猜你喜欢
  • 2021-03-19
  • 1970-01-01
  • 2013-01-08
  • 2019-07-12
  • 2022-10-17
  • 1970-01-01
  • 2015-12-09
  • 2011-10-21
  • 2016-04-26
相关资源
最近更新 更多