尝试使用react-native-fs保存图像时出现“目录上的非法操作”

时间:2020-03-02 17:17:00

标签: react-native

我需要将图像保存在应用程序的特定文件夹中。我正在使用lib react-native-fs。

export const saveGalery = async (viewShot, page) => {
var path = RNFS.DocumentDirectoryPath;
let tmp;
try {
   viewShot.current.capture().then(uri => {
   tmp = uri;

   RNFS.writeFile(path, tmp, 'utf8')
    .then(success => {
      alert('FILE WRITTEN!');
    })
    .catch(err => {
      alert(err.message);
    });
  });
  } catch (e) {
   alert('Não salvo: ' + e);
 }
};

enter image description here

0 个答案:

没有答案