How to use the expo-file-system.getInfoAsync function in expo-file-system

To help you get started, we’ve selected a few expo-file-system 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 flow-typed / flow-typed / definitions / npm / expo-file-system_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-file-system.js View on Github external
it('should raises an error when pass invalid arguments', () => {
    // $ExpectError: first argument is required
    getInfoAsync();
    // $ExpectError: first argument must be a string
    getInfoAsync(69);
    // $ExpectError: second argument must be an object
    getInfoAsync('', 69);

    // $ExpectError: 'abc' is missing in options
    getInfoAsync('', { abc: 'test' });

    getInfoAsync('', {
      // $ExpectError
      md5: 'need number',
    });
  });
});
github flow-typed / flow-typed / definitions / npm / expo-file-system_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-file-system.js View on Github external
it('should raises an error when pass invalid arguments', () => {
    // $ExpectError: first argument is required
    getInfoAsync();
    // $ExpectError: first argument must be a string
    getInfoAsync(69);
    // $ExpectError: second argument must be an object
    getInfoAsync('', 69);

    // $ExpectError: 'abc' is missing in options
    getInfoAsync('', { abc: 'test' });

    getInfoAsync('', {
      // $ExpectError
      md5: 'need number',
    });
  });
});
github wcandillon / react-native-expo-image-cache / src / CacheManager.ts View on Github external
const getCacheEntry = async (uri: string): Promise<{ exists: boolean; path: string; tmpPath: string }> => {
    const filename = uri.substring(uri.lastIndexOf("/"), uri.indexOf("?") === -1 ? uri.length : uri.indexOf("?"));
    const ext = filename.indexOf(".") === -1 ? ".jpg" : filename.substring(filename.lastIndexOf("."));
    const path = `${BASE_DIR}${SHA1(uri)}${ext}`;
    const tmpPath = `${BASE_DIR}${SHA1(uri)}-${_.uniqueId()}${ext}`;
    // TODO: maybe we don't have to do this every time
    try {
        await FileSystem.makeDirectoryAsync(BASE_DIR);
    } catch (e) {
        // do nothing
    }
    const info = await FileSystem.getInfoAsync(path);
    const { exists } = info;
    return { exists, path, tmpPath };
};
github expo / expo / apps / native-component-list / src / screens / FileSystemScreen.tsx View on Github external
_getInfo = async () => {
    if (!this.download) {
      alert('Initiate a download first!');
      return;
    }
    try {
      const info = await FileSystem.getInfoAsync(this.download._fileUri);
      Alert.alert('File Info:', JSON.stringify(info), [{ text: 'OK', onPress: () => {} }]);
    } catch (e) {
      console.log(e);
    }
  }
github expo / expo / packages / expo / build / DataMigrationHelper.js View on Github external
async function treeSearch(relativePath, legacyPath, newPath, resolveConflict) {
    const currentNewPath = `${newPath}${relativePath}`;
    const currentLegacyPath = `${legacyPath}${relativePath}`;
    const legacyPathInfo = await FileSystem.getInfoAsync(currentLegacyPath);
    const newPathInfo = await FileSystem.getInfoAsync(currentNewPath);
    if (legacyPathInfo.exists && !newPathInfo.exists) {
        await FileSystem.copyAsync({
            from: currentLegacyPath,
            to: currentNewPath,
        });
        await FileSystem.deleteAsync(currentLegacyPath);
        return;
    }
    if (legacyPathInfo.isDirectory) {
        const children = await FileSystem.readDirectoryAsync(currentLegacyPath);
        for (let child of children) {
            await treeSearch(relativePath + `${child}/`, legacyPath, newPath, resolveConflict);
        }
    }
    else {
github expo / expo-asset-utils / src / fileInfoAsync.js View on Github external
async function getHashAsync(uri: string): Promise {
  const { md5 } = await FileSystem.getInfoAsync(uri, { md5: true });
  return md5;
}
github Nohac / redux-persist-expo-fs-storage / index.js View on Github external
withCallback(callback, async () => {
      const pathKey = pathForKey(key);
      const { exists } = await FileSystem.getInfoAsync(pathKey);
      if (exists) {
        return await FileSystem.readAsStringAsync(pathKey);
      }
    });
github Nohac / redux-persist-expo-fs-storage / index.js View on Github external
withCallback(callback, async () => {
      const { exists } = await FileSystem.getInfoAsync(baseFolder);
      if (exists == false) {
        await FileSystem.makeDirectoryAsync(baseFolder, {
          intermediates: true,
        });
      }
      await FileSystem.writeAsStringAsync(pathForKey(key), value);
    });
github wcandillon / react-native-expo-image-cache / src / CacheManager.ts View on Github external
static async getCacheSize(): Promise {
        const { size } = await FileSystem.getInfoAsync(BASE_DIR, { size: true });
        return size;
    }
}