How to use the react-native-fs.LibraryDirectoryPath function in react-native-fs

To help you get started, we’ve selected a few react-native-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cllemon / reactNativeSharedBook / app / plugin / utils.js View on Github external
export const generateLocalPath = async (url, format) => {
  try {
    const ABSOLUTEPATH = common.ios
      ? REACTNATIVEFS.LibraryDirectoryPath
      : REACTNATIVEFS.ExternalDirectoryPath;
    const STORAGEPATH = `${ABSOLUTEPATH}/${Date.now()}.${format}`;
    const { statusCode } = await REACTNATIVEFS.downloadFile({
      fromUrl: url,
      toFile: STORAGEPATH
    }).promise;
    if (statusCode === 200) return `file://${STORAGEPATH}`;
    return false;
  } catch (error) {
    console.error('生成本地路径异常', error);
  }
};
github d2rivendell / react-native-GCore / app / components / other / timeLine / TimeLine.js View on Github external
_download(){
        const {timeLine,} = this.props
        var localPath = RNFS.LibraryDirectoryPath + '/' + this.state.pageInfo.id + '.mp3'
        if(Platform.OS === 'android'){
            localPath = RNFS.ExternalDirectoryPath + '/' + this.state.pageInfo.id + '.mp3'
        }
        let downloadManager = new DownloadManager()

        if(downloadManager.isDownloading ){
            Alert.alert('提示','已有任务在队列中',[{text:'确定',onPress:()=>{console.log('sure')} }])
            return
        }

        console.log(localPath)
        let starage = new MyStorage()
        starage.getAudioInfo(this.state.pageInfo.id,(res)=>{
            if(res){
                Alert.alert('提示','资源已经下载',[{text:'确定',onPress:()=>{console.log('sure')} }])
            }else{
github d2rivendell / react-native-GCore / app / components / other / DownloadList.js View on Github external
_deleteRow(rowId,id){
        var path = RNFS.LibraryDirectoryPath + '/' + id + '.mp3'
        if(Platform.OS === 'android'){
            path = RNFS.ExternalDirectoryPath + '/' + id + '.mp3'
        }
        Alert.alert('确定要删除吗?',path,[{text:'取消',onPress:null},{text:'确定',onPress:()=>{
            storage.removeAudioInfo(id)
            RNFS.unlink(path)
                .then(() => {
                    this.getData()
                })
                .catch((err) => {
                    console.log(err.message);
                });
        } }])

    }
    _renderHiddenRow(data, secId, rowId, rowMap){
github cllemon / reactNativeDemo / app / common / utils.js View on Github external
export const generateLocalPath = async (url, format) => {
  try {
    const ABSOLUTEPATH = VALUE.ios
      ? REACTNATIVEFS.LibraryDirectoryPath
      : REACTNATIVEFS.ExternalDirectoryPath;
    const STORAGEPATH = `${ABSOLUTEPATH}/${Date.now()}.${format}`;
    const { statusCode } = await REACTNATIVEFS.downloadFile({
      fromUrl: url,
      toFile: STORAGEPATH
    }).promise;
    if (statusCode === 200) return `file://${STORAGEPATH}`;
    return false;
  } catch (error) {
    console.error('生成本地路径异常', error);
  }
};
github blefebvre / react-native-sqlite-demo / src / sync / dropbox / DropboxDatabaseSync.ts View on Github external
private getLocalDBBackupFilePath(): string {
    return (
      RNFS.LibraryDirectoryPath +
      "/LocalDatabase/" +
      this.getDatabaseBackupName()
    );
  }
}
github blefebvre / react-native-sqlite-demo / src / sync / dropbox / DropboxDatabaseSync.ts View on Github external
private getLocalDBFilePath(): string {
    return (
      RNFS.LibraryDirectoryPath + "/LocalDatabase/" + this.getDatabaseName()
    );
  }
github d2rivendell / react-native-GCore / app / components / other / timeLine / AudioPlayer.js View on Github external
initializeUrl(){
        const {pageInfo,play} = this.props
        if(pageInfo){
            if(!play.isPlay && pageInfo.media.mp3[0]) {
                var audioUrl = pageInfo.media.mp3[0]
                if(pageInfo.localFile){
                    if(Platform.OS === 'android'){
                        audioUrl = RNFS.ExternalDirectoryPath + '/' + pageInfo.id + '.mp3'
                    }else {
                        audioUrl = RNFS.LibraryDirectoryPath + '/' + pageInfo.id + '.mp3'
                    }
                    audioUrl = "file://" + audioUrl
                }
                this.terminate()
                let track = {
                    id: ''+pageInfo.id,
                    url:audioUrl,
                    title: pageInfo.title,
                    artist: pageInfo.desc,
                    artwork:pageInfo.thumb_url
                }
                TrackPlayer.add(track);
            }
        }

    }