Last active
January 17, 2018 14:26
-
-
Save 1c7/ff020daa0b939737f3caa2ca0d1785be to your computer and use it in GitHub Desktop.
(React Native 0.51) save image file from App to Local(no network request)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RNFetchBlob from 'react-native-fetch-blob'; | |
import RNFS from'react-native-fs'; | |
let dirs = RNFetchBlob.fs.dirs | |
const file_path = dirs.DCIMDir + '/' + 'wechat.jpg'; | |
RNFS.copyFileAssets('wechat.jpg', file_path) | |
.then(() => { | |
RNFetchBlob.fs.scanFile([{ path: file_path }]) | |
}) | |
.catch((error) => console.log(error)); |
if you want test if file exist under /android/app/src/main/assets/
import RNFS from'react-native-fs';
RNFS.existsAssets('wechat.jpg').then((result) => console.log(result));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I hope it save your time.
I spend 30 minute on this. it's ridiculous