How to use react-native-document-picker - 10 common examples

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 laurent22 / joplin / ReactNativeClient / lib / components / screens / note.js View on Github external
return new Promise((resolve) => {
			DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error, res) => {
				if (error) {
					// Also returns an error if the user doesn't pick a file
					// so just resolve with null.
					console.info('pickDocument error:', error);
					resolve(null);
					return;
				}

				resolve(res);
			});
		});
	}
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 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 bnankiewicz / organic / src / modules / startup / screens / splash.tsx View on Github external
const openPicker = async () => {
  console.tron.debug(DocumentPicker.types)
  try {
    const res = await DocumentPicker.pick({
      type: [DocumentPicker.types.allFiles],
    })
    console.log(
      res.uri,
      res.type, // mime type
      res.name,
      res.size
    )
    console.tron.debug('URI')
    console.tron.debug(res)
    const name = decodeURIComponent(res.uri)

    if (name.startsWith(CONTENT_PREFIXES.RESILLIO_SYNC)) {
      const realPath = name.replace(CONTENT_PREFIXES.RESILLIO_SYNC, '')
      const content = await RNFetchBlob.fs.readFile(realPath, 'utf8')
      const stat = await RNFetchBlob.fs.stat(realPath, 'utf8')
github bnankiewicz / organic / src / modules / startup / screens / splash.tsx View on Github external
const openPicker = async () => {
  console.tron.debug(DocumentPicker.types)
  try {
    const res = await DocumentPicker.pick({
      type: [DocumentPicker.types.allFiles],
    })
    console.log(
      res.uri,
      res.type, // mime type
      res.name,
      res.size
    )
    console.tron.debug('URI')
    console.tron.debug(res)
    const name = decodeURIComponent(res.uri)

    if (name.startsWith(CONTENT_PREFIXES.RESILLIO_SYNC)) {
      const realPath = name.replace(CONTENT_PREFIXES.RESILLIO_SYNC, '')
github bnankiewicz / organic / src / modules / startup / screens / splash.tsx View on Github external
const openPicker = async () => {
  console.tron.debug(DocumentPicker.types)
  try {
    const res = await DocumentPicker.pick({
      type: [DocumentPicker.types.allFiles],
    })
    console.log(
      res.uri,
      res.type, // mime type
      res.name,
      res.size
    )
    console.tron.debug('URI')
    console.tron.debug(res)
    const name = decodeURIComponent(res.uri)

    if (name.startsWith(CONTENT_PREFIXES.RESILLIO_SYNC)) {
      const realPath = name.replace(CONTENT_PREFIXES.RESILLIO_SYNC, '')
      const content = await RNFetchBlob.fs.readFile(realPath, 'utf8')
      const stat = await RNFetchBlob.fs.stat(realPath, 'utf8')
      console.tron.debug(stat)
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)
			}
		}
	}