How to use the expo-document-picker.getDocumentAsync function in expo-document-picker

To help you get started, we’ve selected a few expo-document-picker 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 EvanBacon / Lego-Expo / screens / HomeScreen.js View on Github external
onPress={async () => {
        const { type, uri, name, size } = await DocumentPicker.getDocumentAsync(
          {},
        );
        if (type === 'success') {
          onPick && onPick({ uri, name, size });
        }
      }}
    >
github expo / expo / apps / storybook / stories / APIs / Print.stories.js View on Github external
_printDocumentPickerPDFAsync = async () => {
    const { selectedPrinter } = this.state;

    try {
      const document = await DocumentPicker.getDocumentAsync({
        type: 'application/pdf',
      });
      if (document.type !== 'success') {
        throw new Error('User did not select a document');
      }
      await Print.printAsync({
        uri: document.uri,
        printerUrl: selectedPrinter ? selectedPrinter.url : undefined,
      });
    } catch (e) {
      Alert.alert('Something went wrong: ', e.message);
    }
  };
github expo / expo / apps / native-component-list / src / screens / DocumentPickerScreen.tsx View on Github external
_openPicker = async () => {
    const result = await DocumentPicker.getDocumentAsync({
      copyToCacheDirectory: this.state.copyToCache,
    });
    if (result.type === 'success') {
      this.setState({ document: result });
    } else {
      setTimeout(() => {
        Alert.alert('Document picked', JSON.stringify(result, null, 2));
      }, 100);
    }
  }
github expo / expo / apps / native-component-list / src / screens / PrintScreen.tsx View on Github external
_printDocumentPickerPDFAsync = async () => {
    const { selectedPrinter } = this.state;

    try {
      const document = await DocumentPicker.getDocumentAsync({
        type: 'application/pdf',
      });
      if (document.type !== 'success') {
        throw new Error('User did not select a document');
      }
      await Print.printAsync({
        uri: document.uri,
        printerUrl: selectedPrinter ? selectedPrinter.url : undefined,
      });
    } catch (e) {
      Alert.alert('Something went wrong: ', e.message);
    }
  }

expo-document-picker

Provides access to the system's UI for selecting documents from the available providers on the user's device.

MIT
Latest version published 1 month ago

Package Health Score

95 / 100
Full package analysis

Popular expo-document-picker functions