How to use the react-native-fs.copyFileAssets 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 PSPDFKit / react-native / samples / Catalog / Catalog.android.js View on Github external
.then(exist => {
            // Check if the file is present in the assets folder.
            if (exist) {
              // File exists so it can be extracted to the external storage directory.
              RNFS.copyFileAssets(assetFile, "/sdcard/" + assetFile)
                .then(() => {
                  // File copied successfully from assets folder to external storage directory.
                  callback();
                })
                .catch(error => {
                  console.log(error);
                });
            } else {
              // File does not exist, it should never happen.
              throw new Error(
                assetFile +
                  " couldn't be extracted as it was not found in the project assets folder."
              );
            }
          })
          .catch(error => {
github tanersener / react-native-ffmpeg / test-app / src / VideoUtil.js View on Github external
async function androidResourcePath(resourceName) {
    var destinationPath = RNFS.CachesDirectoryPath + '/' + resourceName;

    await RNFS.copyFileAssets(resourceName, destinationPath).catch((err) => {
        console.log('Failed to copy android resource: ' + resourceName + ', err message: ' + err.message + ', err code: ' + err.code);
        return undefined;
    });

    return destinationPath;
}
github sonnylazuardi / bibleify-mobile / old / src / app.js View on Github external
componentWillMount() {
    RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm");
    RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
    if (Platform.OS == "android") {
      RNFS.copyFileAssets("nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
      RNFS.copyFileAssets("nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
    } else {
      try {
        RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
        RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
      } catch (e) {
        console.log("FILE ALREADY EXISTS");
      }
    }
  }
  _onShowSearch() {
github sonnylazuardi / bibleify-mobile / old / src / app.js View on Github external
componentWillMount() {
    RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm");
    RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
    if (Platform.OS == "android") {
      RNFS.copyFileAssets("nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
      RNFS.copyFileAssets("nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
    } else {
      try {
        RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
        RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
      } catch (e) {
        console.log("FILE ALREADY EXISTS");
      }
    }
  }
  _onShowSearch() {
github sonnylazuardi / bibleify-mobile / old / src / screens / Passage / PassageScreen.js View on Github external
() => {
        if (Platform.OS == "android") {
          RNFS.copyFileAssets(`${book}.realm.lock`, RNFS.DocumentDirectoryPath + `/${book}.realm.lock`);
          RNFS.copyFileAssets(`${book}.realm`, RNFS.DocumentDirectoryPath + `/${book}.realm`).then(() => {
            this.loadPassage();
            this._bottomSheet.close();
          });
        } else {
          try {
            RNFS.copyFile(
              RNFS.MainBundlePath + `/${book}.realm.lock`,
              RNFS.DocumentDirectoryPath + `/${book}.realm.lock`
            );
            RNFS.copyFile(
              RNFS.MainBundlePath + `/${book}.realm`,
              RNFS.DocumentDirectoryPath + `/${book}.realm`
            ).then(() => {
              this.loadPassage();
              this._bottomSheet.close();
            });
github sonnylazuardi / bibleify-mobile / old / src / screens / Passage / PassageScreen.js View on Github external
() => {
        if (Platform.OS == "android") {
          RNFS.copyFileAssets(`${book}.realm.lock`, RNFS.DocumentDirectoryPath + `/${book}.realm.lock`);
          RNFS.copyFileAssets(`${book}.realm`, RNFS.DocumentDirectoryPath + `/${book}.realm`).then(() => {
            this.loadPassage();
            this._bottomSheet.close();
          });
        } else {
          try {
            RNFS.copyFile(
              RNFS.MainBundlePath + `/${book}.realm.lock`,
              RNFS.DocumentDirectoryPath + `/${book}.realm.lock`
            );
            RNFS.copyFile(
              RNFS.MainBundlePath + `/${book}.realm`,
              RNFS.DocumentDirectoryPath + `/${book}.realm`
            ).then(() => {
              this.loadPassage();
              this._bottomSheet.close();
github sonnylazuardi / bibleify-mobile / src / models / bible.ts View on Github external
loadVersion(payload, rootState) {
      const activeVersion = rootState.bible.activeVersion.value;
      if (Platform.OS == 'ios') {
        RNFS.copyFile(
          RNFS.MainBundlePath + `/${activeVersion}.realm`,
          RNFS.DocumentDirectoryPath + `/${activeVersion}.realm`,
        );
      } else {
        RNFS.copyFileAssets(`${activeVersion}.realm`, `${RNFS.DocumentDirectoryPath}/${activeVersion}.realm`);
      }
    },
    fetchVerses(payload, rootState) {