How to use the react-native-document-picker.isCancel function in react-native-document-picker

To help you get started, we’ve selected a few react-native-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 berty / berty / js / packages / components / main / home / MultiAccount.tsx View on Github external
onPress={async () => {
						try {
							const res = await DocumentPicker.pick({
								// @ts-ignore
								type: ['public.tar-archive', '*/*'],
							})

							await importAccount(res.uri.replace(/^file:\/\//, ''))
						} catch (err) {
							if (DocumentPicker.isCancel(err)) {
								// ignore
							} else {
								console.error(err)
							}
						}
					}}
					avatar={
github berty / berty / js / packages / components / onboarding / AccountSelector.tsx View on Github external
onPress={async () => {
						try {
							const res = await DocumentPicker.pick({
								// @ts-ignore
								type: ['public.tar-archive', '*/*'],
							})

							await importAccount(res.uri.replace(/^file:\/\//, ''))
						} catch (err) {
							if (DocumentPicker.isCancel(err)) {
								// ignore
							} else {
								console.error(err)
							}
						}
					}}
					icon={'upload-outline'}
github berty / berty / js / packages / components / onboarding / CreateAccount.js View on Github external
const onImportPress = async () => {
		try {
			const res = await DocumentPicker.pick({
				// @ts-ignore
				type: ['public.tar-archive', '*/*'],
			})

			await ctx.importAccount(res.uri.replace(/^file:\/\//, ''))
		} catch (err) {
			if (DocumentPicker.isCancel(err)) {
				// ignore
			} else {
				console.error(err)
			}
		}
	}
github iotaledger / trinity-wallet / src / mobile / src / ui / components / SeedVaultImportComponent.js View on Github external
.catch((error) => {
                // Do not show an alert if user cancels and does not pick a file
                if (!DocumentPicker.isCancel(error)) {
                    return this.props.generateAlert(
                        'error',
                        t('global:somethingWentWrong'),
                        t('global:somethingWentWrongTryAgain'),
                        10000,
                        error,
                    );
                }
            });
    }
github berty / berty / js / packages / components / chat / file-uploads / AddFileMenu.tsx View on Github external
onPress: async () => {
				setActiveTab(TabItems.Files)
				try {
					const res = await DocumentPicker.pick({
						type: [DocumentPicker.types.allFiles],
					})
					prepareMediaAndSend([
						{
							filename: res.name,
							uri: res.uri,
							mimeType: res.type,
						},
					])
				} catch (err) {
					if (DocumentPicker.isCancel(err)) {
						// ignore
					}
				}
			},
		},
github RocketChat / Rocket.Chat.ReactNative / app / views / NewServerView.js View on Github external
type: ['com.rsa.pkcs-12']
			});
			const { uri: path, name } = res;
			Alert.prompt(
				I18n.t('Certificate_password'),
				I18n.t('Whats_the_password_for_your_certificate'),
				[
					{
						text: 'OK',
						onPress: password => this.saveCertificate({ path, name, password })
					}
				],
				'secure-text'
			);
		} catch (e) {
			if (!DocumentPicker.isCancel(e)) {
				log(e);
			}
		}
	}
github RocketChat / Rocket.Chat.ReactNative / app / containers / MessageBox / index.js View on Github external
chooseFile = async() => {
		try {
			const res = await DocumentPicker.pick({
				type: [DocumentPicker.types.allFiles]
			});
			this.showUploadModal({
				filename: res.name,
				size: res.size,
				mime: res.type,
				path: res.uri
			});
		} catch (e) {
			if (!DocumentPicker.isCancel(e)) {
				log(e);
			}
		}
	}