2018 React Native save image file from App to Phone

Code here

tested under React Native 0.51 and Android.

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));

file should place under
/android/app/src/main/assets/

example

/android/app/src/main/assets/wechat.jpg

if you want test if file exist

RNFS.existsAssets('wechat.jpg').then((result) => console.log(result));
使用 Hugo 构建
主题 StackJimmy 设计