How to use the react-native-fs.mkdir 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 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 josephroquedev / campus-guide / old / js / util / Configuration.js View on Github external
async function _updateConfig(callbacks: ConfigurationUpdateCallbacks): Promise < void > {
  if (configurationUpdates.length === 0) {
    // If there are no updates, exit
    return;
  }

  // Generate directories
  await RNFS.mkdir(CONFIG_DIRECTORY);
  await RNFS.mkdir(TEMP_CONFIG_DIRECTORY);
  for (const type in CONFIG_SUBDIRECTORIES) {
    if (CONFIG_SUBDIRECTORIES.hasOwnProperty(type)) {
      await RNFS.mkdir(CONFIG_DIRECTORY + CONFIG_SUBDIRECTORIES[type]);
    }
  }

  // Get total size of update
  let totalSize: number = 0;
  for (let i = 0; i < configurationUpdates.length; i++) {
    totalSize += configurationUpdates[i].size;
  }
  if (callbacks.onUpdateStart) {
    callbacks.onUpdateStart(totalSize, configurationUpdates.length);
  }
github josephroquedev / campus-guide / old / js / util / Configuration.js View on Github external
async function _updateConfig(callbacks: ConfigurationUpdateCallbacks): Promise < void > {
  if (configurationUpdates.length === 0) {
    // If there are no updates, exit
    return;
  }

  // Generate directories
  await RNFS.mkdir(CONFIG_DIRECTORY);
  await RNFS.mkdir(TEMP_CONFIG_DIRECTORY);
  for (const type in CONFIG_SUBDIRECTORIES) {
    if (CONFIG_SUBDIRECTORIES.hasOwnProperty(type)) {
      await RNFS.mkdir(CONFIG_DIRECTORY + CONFIG_SUBDIRECTORIES[type]);
    }
  }

  // Get total size of update
  let totalSize: number = 0;
  for (let i = 0; i < configurationUpdates.length; i++) {
    totalSize += configurationUpdates[i].size;
  }
  if (callbacks.onUpdateStart) {
    callbacks.onUpdateStart(totalSize, configurationUpdates.length);
  }

  // Add filename to download info and invoke start callback
  const onStart = (filename: string, download: Object) => {
    if (callbacks.onDownloadStart) {
      download.filename = filename;
github josephroquedev / campus-guide / src / util / Configuration.ts View on Github external
async function _updateConfig(
    configDetails: ConfigurationDetails,
    callbacks: UpdateCallbacks,
    os: PlatformOSType): Promise {
  if (configDetails.files.length === 0) {
    // If there are no updates, exit
    return;
  }

  // Generate directories
  await RNFS.mkdir(CONFIG_DIRECTORY);
  await RNFS.mkdir(TEMP_CONFIG_DIRECTORY);
  for (const type in CONFIG_SUBDIRECTORIES) {
    if (CONFIG_SUBDIRECTORIES.hasOwnProperty(type)) {
      await RNFS.mkdir(CONFIG_DIRECTORY + CONFIG_SUBDIRECTORIES[type]);
    }
  }

  // Get total size of update
  let totalSize = 0;
  for (const update of configDetails.files) {
    totalSize += update.size;
  }

  if (callbacks.onUpdateStart) {
    callbacks.onUpdateStart(totalSize, configDetails.files.length);
  }
github josephroquedev / campus-guide / old / js / util / Configuration.js View on Github external
async function _updateConfig(callbacks: ConfigurationUpdateCallbacks): Promise < void > {
  if (configurationUpdates.length === 0) {
    // If there are no updates, exit
    return;
  }

  // Generate directories
  await RNFS.mkdir(CONFIG_DIRECTORY);
  await RNFS.mkdir(TEMP_CONFIG_DIRECTORY);
  for (const type in CONFIG_SUBDIRECTORIES) {
    if (CONFIG_SUBDIRECTORIES.hasOwnProperty(type)) {
      await RNFS.mkdir(CONFIG_DIRECTORY + CONFIG_SUBDIRECTORIES[type]);
    }
  }

  // Get total size of update
  let totalSize: number = 0;
  for (let i = 0; i < configurationUpdates.length; i++) {
    totalSize += configurationUpdates[i].size;
  }
  if (callbacks.onUpdateStart) {
    callbacks.onUpdateStart(totalSize, configurationUpdates.length);
  }

  // Add filename to download info and invoke start callback
github egm0121 / splitcloud-app / modules / MediaLibraryApi.js View on Github external
createLibraryArtworkCache(){
    return RNFS.mkdir(APP_ARTWORK_CACHE_FOLDER,{NSURLIsExcludedFromBackupKey : true})
    .then(() => {
      console.log('MediaLibraryApi asset caching dir :',APP_ARTWORK_CACHE_FOLDER);
    });
  }
  refreshLibraryArtworks(){
github cliqz-oss / browser-core / platforms / react-native / persistent-map.es View on Github external
async init() {
    await RNFS.mkdir(this._mapDir);
    return Promise.resolve();
  }
github mohebifar / react-native-ximage / src / Storage.js View on Github external
createCacheDirectory() {
    fs.mkdir(this.getCacheDirectory());
  }
github le0zh / gitbook-reader-rn / src / data / bookFiles.js View on Github external
RNFS.exists(dir).then(dirExists => {
      if (dirExists) {
        resolve();
      } else {
        RNFS.mkdir(dir).then(() => {
          resolve();
        });
      }
    });
  });