How to use the expo-image-picker.launchImageLibraryAsync function in expo-image-picker

To help you get started, we’ve selected a few expo-image-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 SCasarotto / casarotto-chat / src / pages / Main / Main.js View on Github external
.then((response) => {
				const { status, expires, permissions } = response
				if (status === 'granted') {
					ImagePicker.launchImageLibraryAsync({
						// mediaTypes: 'All',
						base64: true,
						quality: 1,
					})
						.then((response) => {
							if (!response.cancelled) {
								const { user, sendImage } = this.props
								//TODO: Check if it is a video and store video
								const data = { uri: response.uri, user }
								sendImage(data)
							}
						})
						.catch((error) => console.log(error))
				}
			})
			.catch((error) => console.log(error))
github SCasarotto / casarotto-chat / src / pages / Profile / Profile.js View on Github external
.then((response) => {
				const { status } = response
				if (status === 'granted') {
					ImagePicker.launchImageLibraryAsync({
						allowsEditing: true,
						aspect: [1, 1],
						base64: true,
						quality: 0.5,
					})
						.then((response) => {
							if (!response.cancelled) {
								this.props.uploadImage(response.uri)
							}
						})
						.catch((error) => console.log(error))
				}
			})
			.catch((error) => console.log(error))
github SCasarotto / casarotto-chat / src / pages / Setup / Setup.js View on Github external
.then((response) => {
				const { status, expires, permissions } = response
				if (status === 'granted') {
					ImagePicker.launchImageLibraryAsync({
						allowsEditing: true,
						aspect: [1, 1],
						quality: 0.5,
					})
						.then((response) => {
							console.log(response)
							if (!response.cancelled) {
								this.props.uploadImage(response.uri)
							}
						})
						.catch((error) => console.log(error))
				}
			})
			.catch((error) => console.log(error))
github sysgears / apollo-universal-starter-kit / modules / chat / client-react / containers / withImage.jsx View on Github external
pickImage = async ({ onSend }) => {
      const { t } = this.props;
      if (await this.checkPermission(Permissions.CAMERA_ROLL, 'android')) {
        const { cancelled, uri } = await ImagePicker.launchImageLibraryAsync(settings.chat.image.imagePicker);
        if (!cancelled) {
          const { size } = await FileSystem.getInfoAsync(uri);
          const reg = /[^\\/]*\.\w+$/;
          if (size <= settings.chat.image.maxSize && reg.test(uri)) {
            const type = mime.lookup(uri);
            const name = uri.match(reg)[0];
            const imageData = new ReactNativeFile({ uri, type, name });
            onSend({ attachment: imageData });
          } else {
            this.setState({ notify: t('attachment.errorMsg') });
          }
        }
      } else {
        this.setState({ notify: t('permission.errorMsg') });
      }
    };
github FaridSafi / react-native-gifted-chat / example-expo / mediaUtils.js View on Github external
export async function pickImageAsync(onSend) {
  if (await getPermissionAsync(Permissions.CAMERA_ROLL)) {
    const result = await ImagePicker.launchImageLibraryAsync({
      allowsEditing: true,
      aspect: [4, 3],
    })

    if (!result.cancelled) {
      onSend([{ image: result.uri }])
      return result.uri
    }
  }
}
github keybase / client / shared / util / expo-image-picker.tsx View on Github external
export const launchImageLibraryAsync = (
  mediaType: 'photo' | 'video' | 'mixed',
  askPermAndRetry: boolean = true
): Promise => {
  return ImagePicker.launchImageLibraryAsync({mediaTypes: mediaTypeToImagePickerMediaType(mediaType)}).catch(
    retyAfterAskingPerm(
      [Permissions.CAMERA_ROLL],
      askPermAndRetry ? () => launchImageLibraryAsync(mediaType, false) : null
    )
  )
}
github EvanBacon / firebase-instagram / screens / SelectPhotoScreen.js View on Github external
_selectPhoto = async () => {
    const status = await getPermission(Permissions.CAMERA_ROLL);
    if (status) {
      const result = await ImagePicker.launchImageLibraryAsync(options);
      if (!result.cancelled) {
        this.props.navigation.navigate("NewPost", { image: result.uri });
      }
    }
  };
github expo / expo / home / utils / ImageSelectionUtils.ts View on Github external
export async function choosePhotoAsync(): Promise {
  if (!(await ensurePermissionsAsync())) return null;

  const media = await ImagePicker.launchImageLibraryAsync(mediaOptions);
  if (!media.cancelled) {
    return await moveToPhotoCacheAsync(media.uri);
  }
  return null;
}

expo-image-picker

Provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera.

MIT
Latest version published 9 hours ago

Package Health Score

95 / 100
Full package analysis