javascriptreact-nativecamera-roll

React Native save a http Image to Android camera roll


Here are some images from websites and I want to save them to Android camera roll.

I found out that React Native has an function CameraRoll.saveImageWithTag which could save certain image into the camera roll, but the param tag should be a local URI, such as "file:///sdcard/img.png". So how to save the image in Android React Native if the image source was not local?


Solution

  • You need to download the file first. You can use react-native-fetch-blob to do that

    Or, if you are using Expo you can use FileSystem.downloadAsync.

    Those will give you a local Uri to use with CameraRoll.save... (I think it has a different name now)