React Native save base64 image to Album

前端 未结 5 1761
没有蜡笔的小新
没有蜡笔的小新 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:53

    You can now use only react native fetch blob to achieve this.

    Simply replace RNFS.writeFile with

    RNFetchBlob.fs.writeFile(file_path, image_data, 'base64')
    

    If you wish to view file in native OS viewer you can simply put

                    if (isAndroid) {
                      RNFetchBlob.android.actionViewIntent(file_path, 'application/pdf');
                    } else {
                      RNFetchBlob.ios.previewDocument(file_path);
                    }
    

提交回复
热议问题