React Native save base64 image to Album

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

    Remove data:image/png;base64, in your base64 string

    var Base64Code = base64Image.split("data:image/png;base64,"); //base64Image is my image base64 string
    
    const dirs = RNFetchBlob.fs.dirs;
    
    var path = dirs.DCIMDir + "/image.png";
    
    RNFetchBlob.fs.writeFile(path, Base64Code[1], 'base64')
    .then((res) => {console.log("File : ", res)});
    

    And then I solved my problem.

提交回复
热议问题