How to use the react-native-fs.CachesDirectoryPath 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 celo-org / celo-monorepo / packages / mobile / src / sentry / Sentry.ts View on Github external
const uploadNdkCrashesIfAny = async () => {
  // This file path should be same here and in MainApplication.java
  const ndkCrashLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logs.txt'
  const ndkCrashLogcatLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logcat_logs.txt'

  if (!(await RNFS.exists(ndkCrashLogsFilePath))) {
    Logger.debug(
      'Sentry@uploadNdkCrashesIfAny',
      `crash log file ${ndkCrashLogsFilePath} not found, no native crashes recorded`
    )
    return
  }

  const fileSize = parseInt((await RNFS.stat(ndkCrashLogsFilePath)).size, 10)
  Logger.info(
    'Sentry@uploadNdkCrashesIfAny',
    `crash log file ${ndkCrashLogsFilePath} found (${fileSize} bytes), capturing it via Sentry`
  )
  const msg1 = (await RNFS.exists(ndkCrashLogcatLogsFilePath))
    ? await RNFS.readFile(ndkCrashLogcatLogsFilePath)
github celo-org / celo-monorepo / packages / mobile / src / sentry / Sentry.ts View on Github external
const uploadNdkCrashesIfAny = async () => {
  // This file path should be same here and in MainApplication.java
  const ndkCrashLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logs.txt'
  const ndkCrashLogcatLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logcat_logs.txt'

  if (!(await RNFS.exists(ndkCrashLogsFilePath))) {
    Logger.debug(
      'Sentry@uploadNdkCrashesIfAny',
      `crash log file ${ndkCrashLogsFilePath} not found, no native crashes recorded`
    )
    return
  }

  const fileSize = parseInt((await RNFS.stat(ndkCrashLogsFilePath)).size, 10)
  Logger.info(
    'Sentry@uploadNdkCrashesIfAny',
    `crash log file ${ndkCrashLogsFilePath} found (${fileSize} bytes), capturing it via Sentry`
  )
  const msg1 = (await RNFS.exists(ndkCrashLogcatLogsFilePath))
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 ramneekhanda / react-native-ffmpeg / test_app / index.android.js View on Github external
onConvert() {
    var localInputFileName = "";
    var randomFileName = RNFS.CachesDirectoryPath + "/" + Math.random().toString(36).substring(5) + ".gif";
    var resolvedFile = localInputFileName = "http://techslides.com/demos/sample-videos/small.mp4";

    this.setState({
      fileName: randomFileName,
      imageAvailable: false,
      progress: 0.001
    });

    console.log("resolved file " + resolvedFile);
    console.log("writing output file " + randomFileName);
    var remoteFileName = this.getRemoteFileName(resolvedFile);
    const progress = p => { 
      var prog = p.progress/100
      this.setState({
        progress: prog
      });
github ramneekhanda / react-native-ffmpeg / ffmpeg_test_app / index.android.js View on Github external
var randomFileName = RNFS.CachesDirectoryPath + "/" + Math.random().toString(36).substring(5) + ".gif";
    var resolvedFile = localInputFileName = "http://techslides.com/demos/sample-videos/small.mp4";

    this.setState({
      fileName: randomFileName,
      imageAvailable: false
    });

    console.log("resolved file " + resolvedFile);
    console.log("writing output file " + randomFileName);
    var remoteFileName = this.getRemoteFileName(resolvedFile);
    const progress = p => { 
      console.log("javascript completed percent - " + p.progress); 
    }
    if (resolvedFile.search(/http/i) >= 0) {
      var localInputFileName = RNFS.CachesDirectoryPath + "/" + remoteFileName;
      console.log("remote file is being used - probably running under debugger. Will download the file now");
      console.log("Downloading to file " + localInputFileName);
      RNFS.downloadFile({
        fromUrl: resolvedFile,
        toFile: localInputFileName
      }).promise.then(res => {
        console.log("Downloaded file file://" + localInputFileName);
        this.setState({
          imageAvailable: false
        });
        ReactNativeFFMpeg.encodeVideoOnly(
          {
            fromFile: localInputFileName,
            toFile: randomFileName,
            progress
          }
github gaoxiaosong / react-native-full-image-picker / src / AlbumView.js View on Github external
const params = uri.split('?');
                if (params.length < 1) {
                    throw new Error('Unknown URI:' + uri);
                }
                const keyValues = params[1].split('&');
                if (keyValues.length < 2) {
                    throw new Error('Unknown URI:' + uri);
                }
                const kvMaps = keyValues.reduce((prv, cur) => {
                    const kv = cur.split('=');
                    prv[kv[0]] = kv[1];
                    return prv;
                }, {});
                const itemId = kvMaps.id;
                const ext = kvMaps.ext.toLowerCase();
                const destPath = RNFS.CachesDirectoryPath + '/' + itemId + '.' + ext;
                let promise;
                if (item.type === 'ALAssetTypePhoto') {
                    promise = RNFS.copyAssetsFileIOS(uri, destPath, 0, 0);
                } else if (item.type === 'ALAssetTypeVideo') {
                    promise = RNFS.copyAssetsVideoIOS(uri, destPath);
                } else {
                    throw new Error('Unknown URI:' + uri);
                }
                return promise
                    .then((resultUri) => {
                        data[index].uri = resultUri;
                    });
            });
            Promise.all(promises)
github crownstone / CrownstoneApp / js / views / saveAndUsageExample.js View on Github external
input.captureFrame({type:'png', format:'file', filePath: path, quality:1}).then((filePath) => {
        LOG('captured!', RNFS.CachesDirectoryPath, filePath, arguments)
        this.state.imagePath = filePath
        this.setState(this.state)
      });
github celo-org / celo-monorepo / packages / mobile / src / utils / Logger.ts View on Github external
getGethLogFilePath = () => {
    return RNFS.CachesDirectoryPath + '/geth_logs.txt'
  }