React Native save base64 image to Album

前端 未结 5 1769
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 21:22

Third Party API return a \"QR code image\" in base64 encode,
I need save that image to User\'s Album.

  • CamerRoll - not support saving base64 image to album <
5条回答
  •  忘了有多久
    2021-02-05 21:47

    const path = `${RNFS.PicturesDirectoryPath}/My Album`;
    await RNFS.mkdir(path);
    return await fetch(uri)
       .then(res => res.blob())
       .then(image => {
          RNFetchBlob.fs.readFile(uri, "base64").then(data => {
             RNFS.appendFile(`${path}/${image.data.name}`, data, "base64").catch(
                err => {
                   console.log("error writing to android storage :", err);
                }
             );
          });
       });

提交回复
热议问题