How to use the react-native-fs.ExternalStorageDirectoryPath 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 smallpath / psnine / psnine / component / ImageViewer / index.android.tsx View on Github external
import {
  ToastAndroid,
  View,
  Animated,
  Easing,
  StatusBar,
  Text
} from 'react-native'

import fs from 'react-native-fs'
import { ViewPagerZoom } from 'react-native-image-zoom'
import PhotoView from 'react-native-photo-view'

declare var global

const psnineFolder = fs.ExternalStorageDirectoryPath + '/psnine'
console.log('==========================>')
fs.stat(psnineFolder).then(data => {
  const isDirectory = data.isDirectory()
  if (!isDirectory) {
    fs.unlink(psnineFolder).catch(() => { }).then(() => fs.mkdir(psnineFolder))
  }
}).catch(() => {
  fs.mkdir(psnineFolder).catch(err => console.log(err, 'ImageViewer:line#27'))
})

const onSave = (image) => {
  // console.log(image, psnineFolder + '/' + image.split('/').pop())
  const result = fs.downloadFile({
    fromUrl: image,
    toFile: psnineFolder + '/' + image.split('/').pop()
  })
github codeestX / MoeFM / js / middleware / downloader.js View on Github external
async function create(song) {
    let existDir = await RNFS.exists(RNFS.ExternalStorageDirectoryPath + '/MoeFM').then(boolean => boolean);
    if (!existDir) await RNFS.mkdir(RNFS.ExternalStorageDirectoryPath + '/MoeFM');
    let exist = await RNFS.exists(RNFS.ExternalStorageDirectoryPath + '/MoeFM/' + song.title + '.mp3').then(boolean => boolean);
    if (!exist) {
        RNFS.downloadFile({
            fromUrl: song.url,
            toFile: RNFS.ExternalStorageDirectoryPath + '/MoeFM/' + song.title + '.mp3',
            background: true,
            begin: ((res) => beginCallback(res, song)),
            progress: (progressCallback)
        }).promise.then((result) => {
            resultCallback(result);
        }).catch((err) => {
                if(err.description === "cancelled") {
                    // cancelled by user
                }
                console.log(err);
github open-app / app-hub-mobile / src / components / ApplicationsView.js View on Github external
handleInstall = (datHash) => {
    try {
      const dest = `${RNFS.ExternalStorageDirectoryPath}/AppHub/${datHash}`
      RNFS.mkdir(dest)
      .then(() => {
        getApkPath(datHash)
        .then(apkPath => {
          if(apkPath) {
            const publicPath = `${dest}${datHash}.apk`
            RNFS.exists(publicPath)
            .then(exists => {
              if(!exists) {
                RNFS.copyFile(apkPath, publicPath)
              }
              ApkInstaller.install(publicPath)
            })
          } else {
            console.warn('APK not found')
          }
github codeestX / MoeFM / js / page / LocalListPage.js View on Github external
*/

import React, {Component} from 'react'
import {
    FlatList,
    Text,
    View,
    StyleSheet
} from 'react-native'
import CustomButton from '../component/CustomButton'
let RNFS = require('react-native-fs');
let Sound = require('react-native-sound');

const MoeFMPath = RNFS.ExternalStorageDirectoryPath + '/MoeFM';
const NetEaseMusicPath = RNFS.ExternalStorageDirectoryPath + '/netease/cloudmusic/Music';
const QQMusicPath = RNFS.ExternalStorageDirectoryPath + '/qqmusic/song';
const KuGouMusicPath = RNFS.ExternalStorageDirectoryPath + '/kgmusic/download';


export default class LocalListPage extends Component {

    constructor(props) {
        super(props);
        this.state = {
            data: [],
        };
    }

    playMusic(path) {
        let sound = new Sound(path, '', (error) => {
            if (error) {
                console.log(error);
github totorototo / strava / app / store / services / helpers / file.js View on Github external
export const readDir = (
  path = `${RNFS.ExternalStorageDirectoryPath}/Download`
) => RNFS.readDir(path);
github codeestX / MoeFM / js / page / LocalListPage.js View on Github external
* @date: 2017/5/18
 * @description:
 */

import React, {Component} from 'react'
import {
    FlatList,
    Text,
    View,
    StyleSheet
} from 'react-native'
import CustomButton from '../component/CustomButton'
let RNFS = require('react-native-fs');
let Sound = require('react-native-sound');

const MoeFMPath = RNFS.ExternalStorageDirectoryPath + '/MoeFM';
const NetEaseMusicPath = RNFS.ExternalStorageDirectoryPath + '/netease/cloudmusic/Music';
const QQMusicPath = RNFS.ExternalStorageDirectoryPath + '/qqmusic/song';
const KuGouMusicPath = RNFS.ExternalStorageDirectoryPath + '/kgmusic/download';


export default class LocalListPage extends Component {

    constructor(props) {
        super(props);
        this.state = {
            data: [],
        };
    }

    playMusic(path) {
        let sound = new Sound(path, '', (error) => {
github staltz / dat-installer / src / frontend / screens / central / index.ts View on Github external
function httpRequests(start$: Stream): Stream {
  const pingReq$ = xs
    .periodic(300)
    .startWith(0)
    .endWhen(start$)
    .mapTo({ category: "ping", url: "/ping" });

  const setStoragePathReq$ = start$.mapTo({
    category: "setStoragePath",
    url: "/setStoragePath",
    method: "POST",
    send: { path: RNFS.ExternalStorageDirectoryPath + "/DatInstaller" },
  });

  const latestReq$ = start$
    .map(() => xs.periodic(2000).startWith(null as any))
    .flatten()
    .mapTo({ category: "latest", url: "/latest" });

  return xs.merge(pingReq$, setStoragePathReq$, latestReq$);
}