How to use the expo-file-system.createDownloadResumable 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 passes when used properly', () => {
    createDownloadResumable('url', 'fileUri', { md5: false });
    createDownloadResumable('url', 'fileUri', { cache: false });
    createDownloadResumable('url', 'fileUri', {
      headers: { 'header-name': 'abc' },
    });
    createDownloadResumable('url', 'fileUri', {
      md5: false,
      cache: false,
      headers: { 'X-Auth': 'abc' },
    });

    const controller = createDownloadResumable('url', 'fileUri');

    (controller: DownloadResumable);
    // $ExpectError: check any
    (controller: 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
    createDownloadResumable();
    // $ExpectError: first argument must be a string
    createDownloadResumable(69);
    // $ExpectError: second argument must be a string
    createDownloadResumable('', 69);
    // $ExpectError: third argument must be an object
    createDownloadResumable('', '', 69);
    // $ExpectError: 'abc' is missing in options
    createDownloadResumable('', '', { abc: 'test' });
    createDownloadResumable('', '', {
      // $ExpectError: invalid value
      md5: 'need boolean',
    });
  });
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
describe('DownloadResumable', () => {
    const controller = createDownloadResumable('url', 'fileUri');

    it('should work when call .downloadAsync()', () => {
      controller.downloadAsync().then(result => {
        if (result) {
          (result.uri: string);
          (result.status: number);
          (result.headers: { [string]: string });
          (result.md5: ?string);
        } else {
          (result: void);
        }

        // $ExpectError: check any
        (result: 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
    createDownloadResumable();
    // $ExpectError: first argument must be a string
    createDownloadResumable(69);
    // $ExpectError: second argument must be a string
    createDownloadResumable('', 69);
    // $ExpectError: third argument must be an object
    createDownloadResumable('', '', 69);
    // $ExpectError: 'abc' is missing in options
    createDownloadResumable('', '', { abc: 'test' });
    createDownloadResumable('', '', {
      // $ExpectError: invalid value
      md5: 'need boolean',
    });
  });
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
    createDownloadResumable();
    // $ExpectError: first argument must be a string
    createDownloadResumable(69);
    // $ExpectError: second argument must be a string
    createDownloadResumable('', 69);
    // $ExpectError: third argument must be an object
    createDownloadResumable('', '', 69);
    // $ExpectError: 'abc' is missing in options
    createDownloadResumable('', '', { abc: 'test' });
    createDownloadResumable('', '', {
      // $ExpectError: invalid value
      md5: 'need boolean',
    });
  });
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
    createDownloadResumable();
    // $ExpectError: first argument must be a string
    createDownloadResumable(69);
    // $ExpectError: second argument must be a string
    createDownloadResumable('', 69);
    // $ExpectError: third argument must be an object
    createDownloadResumable('', '', 69);
    // $ExpectError: 'abc' is missing in options
    createDownloadResumable('', '', { abc: 'test' });
    createDownloadResumable('', '', {
      // $ExpectError: invalid value
      md5: 'need boolean',
    });
  });
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 passes when used properly', () => {
    createDownloadResumable('url', 'fileUri', { md5: false });
    createDownloadResumable('url', 'fileUri', { cache: false });
    createDownloadResumable('url', 'fileUri', {
      headers: { 'header-name': 'abc' },
    });
    createDownloadResumable('url', 'fileUri', {
      md5: false,
      cache: false,
      headers: { 'X-Auth': 'abc' },
    });

    const controller = createDownloadResumable('url', 'fileUri');

    (controller: DownloadResumable);
    // $ExpectError: check any
    (controller: number);
  });
github wcandillon / react-native-expo-image-cache / src / CacheManager.ts View on Github external
async getPath(): Promise {
        const { uri, options } = this;
        const { path, exists, tmpPath } = await getCacheEntry(uri);
        if (exists) {
            return path;
        }
        const result = await FileSystem.createDownloadResumable(uri, tmpPath, options).downloadAsync();
        // If the image download failed, we don't cache anything
        if (result && result.status !== 200) {
            return undefined;
        }
        await FileSystem.moveAsync({ from: tmpPath, to: path });
        return path;
    }
}
github czy0729 / Bangumi / components / @ / react-native-expo-image-cache / src / CacheManager.js View on Github external
async getPath() {
    const { uri, options } = this
    const { path, exists, tmpPath } = await getCacheEntry(uri)
    if (exists) {
      return path
    }
    const result = await FileSystem.createDownloadResumable(
      uri,
      tmpPath,
      options
    ).downloadAsync()
    // If the image download failed, we don't cache anything
    if (result && result.status !== 200) {
      return undefined
    }
    await FileSystem.moveAsync({ from: tmpPath, to: path })
    return path
  }
}
github expo / expo / apps / native-component-list / src / screens / FileSystemScreen.tsx View on Github external
_startDownloading = async () => {
    const url = 'http://ipv4.download.thinkbroadband.com/5MB.zip';
    const fileUri = FileSystem.documentDirectory + '5MB.zip';
    const callback: FileSystem.DownloadProgressCallback = downloadProgress => {
      const progress =
        downloadProgress.totalBytesWritten / downloadProgress.totalBytesExpectedToWrite;
      this.setState({
        downloadProgress: progress,
      });
    };
    const options = { md5: true };
    this.download = FileSystem.createDownloadResumable(url, fileUri, options, callback);

    try {
      await this.download.downloadAsync();
      if (this.state.downloadProgress === 1) {
        alert('Download complete!');
      }
    } catch (e) {
      console.log(e);
    }
  }