Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

How to save remote GIF to album in iOS in React Native?

$
0
0

Thanks for reading, I am trying to save remote GIF to system album in React Native in iOS.

I have try the following ways but all of them making GIFs as static images.

I create a new React Native project of 0.62.2 to run these code

"dependencies": {"@react-native-community/cameraroll": "^1.7.2","react": "16.11.0","react-native": "0.62.2","react-native-fs": "^2.16.6","rn-fetch-blob": "^0.12.0"  }
  1. Save GIF directly by CameraRoll.
    Not working because https://github.com/react-native-community/react-native-cameraroll/issues/16
const uri = 'https://i.loli.net/2020/05/28/YKaCdO1pexuThbN.gif'CameraRoll.saveToCameraRoll(uri);
  1. Download GIF firstly by react-native-fs
const img = 'https://i.loli.net/2020/05/28/YKaCdO1pexuThbN.gif'const storeLocation = `${RNFS.TemporaryDirectoryPath}`;const pathName = `${new Date().getTime()}_babycam_moji.gif`;const downloadPath = `${storeLocation}${pathName}`;const ret = RNFS.downloadFile({  fromUrl: img,  toFile: downloadPath,});ret.promise.then((res) => {  console.log('res', res);  if (res && res.statusCode === 200) {    const promise = CameraRoll.saveToCameraRoll(      `file://${downloadPath}`,    );    promise.then(() => {});  } else {  }});
  1. download GIF firstly by rn-fetch-blob
RNFetchBlob.config({appendExt: 'gif', fileCache: true})  .fetch('GET', img)  .then((res) => {  console.log('res', res.path());  CameraRoll.saveToCameraRoll(res.path());});

How can I save GIFs to album in iOS in react-native?

Thanks


Viewing all articles
Browse latest Browse all 16552

Trending Articles