How to use the expo.ImagePicker.launchImageLibraryAsync function in expo

To help you get started, we’ve selected a few expo 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 / pro-chat / client / src / components / chat / Actions.js View on Github external
_pickImageAsync = async () => {
    const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
    if (status !== 'granted') {
      this.setState({
        errorMessage: 'Permission to access photos was denied',
      });
      return null;
    }

    const result = await ImagePicker.launchImageLibraryAsync({
      allowsEditing: true,
      aspect: [4, 3],
    });

    console.log(result);

    if (!result.cancelled) {
      const storageUrl = await Fire.shared.uploadImageAsync(result.uri);
      console.log('local', result.uri, 'global', storageUrl);
      return storageUrl;
    }
    // Maybe do something

    return null;
  };
github BrightID / BrightID / brightID-expo / src / components / SignUp.js View on Github external
getAvatarPhoto = async () => {
    // expo version
    try {
      let result = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: 'Images',
        base64: true,
      });

      if (!result.cancelled) {
        this.setState({ avatarUri: result.uri });
      }
    } catch (err) {
      console.warn(err);
    }

    // for full documentation on the Image Picker api
    // see https://github.com/react-community/react-native-image-picker

    // const options = {
    //   title: 'Select Avatar',
github joehoyle / vienna / actions / uploadImage.js View on Github external
const takePhoto = option === 0;
			const permission = takePhoto ? Permissions.CAMERA : Permissions.CAMERA_ROLL;

			// Do we have permission?
			let permissions = await Permissions.getAsync( permission );
			if ( permissions.status !== 'granted' ) {
				// Asking for permission...
				permissions = await Permissions.askAsync( permission );
				if ( permissions.status !== 'granted' ) {
					// No permission :(
					return;
				}
			}

			const response = await (
				takePhoto ? ImagePicker.launchCameraAsync( cameraOptions ) : ImagePicker.launchImageLibraryAsync( libraryOptions )
			);

			if ( response.cancelled ) {
				return;
			}

			// You can display the image using either data:
			// dispatch(createPost('attachment'));

			// api
			// 	.upload('/wp/v2/media', response.data, 'image/png', 'test.png')
			// 	.then(data => {
			// 		dispatch({
			// 			type: 'TYPE_POSTS_NEW_UPDATED',
			// 			payload: {
			// 				type: 'attachment',
github DefinitelyTyped / DefinitelyTyped / types / expo / v24 / expo-tests.tsx View on Github external
async () => {
    const result = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: ImagePicker.MediaTypeOptions.Videos
    });

    if (!result.cancelled) {
        result.uri;
        result.width;
        result.height;
    }
};
github npatta01 / mobile-deep-learning-classifier / screens / HomeScreen.js View on Github external
_pickImageFromLibrary = async () => {
        const status = await this._verifyPermissions();

        let result = await ImagePicker.launchImageLibraryAsync({
            allowsEditing: true,
            aspect: [4, 3],
        });

        if (result.cancelled) {
            console.log("Cancelled")
        } else {

            this._processImage(result);
        }
    };
github Tkd-Alex / Garcon-Restaurant-Manager / garcon-react-native / src / screen / registration.js View on Github external
pickImage = async () => {
    let result = await ImagePicker.launchImageLibraryAsync({
      allowsEditing: true
    });

    console.log(result);

    if (!result.cancelled) {
      this.setState({ image: result.uri });
    }
  };
github internxt / X-Cloud-Mobile / src / components / AppMenu / index.js View on Github external
text: 'Upload a picture', onPress: async () => {
          const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
          if (status === 'granted') {
            const result = await ImagePicker.launchImageLibraryAsync()
            if (!result.cancelled) this.uploadFile(result);
          }
        }
      }, {
github EvanBacon / pro-chat / client / src / utils / SelectImage.js View on Github external
export const fromLibrary = async () => {
  const hasit = await getPermission(Permissions.CAMERA_ROLL);
  if (!hasit) return;

  const { cancelled, uri } = await ImagePicker.launchImageLibraryAsync({
    allowsEditing: false,
    aspect: [1, 1],
    quality: 0.85,
    base64: false,
    exif: true,
  });

  if (cancelled) {
    return;
  }

  const { uri: reducedUri } = await reduceImageAsync(uri);

  return reducedUri;
};
export const fromCamera = async () => {
github tus / tus-js-client / demos / reactnative / App.js View on Github external
Permissions.askAsync(Permissions.CAMERA_ROLL).then((isAllowed) => {
      if (!isAllowed) return;

      ImagePicker.launchImageLibraryAsync({})
        .then((result) => {
          if (!result.cancelled) {
            this.setState({
              file: result,
              status: "file selected"
            });
          }
        });
    });
  }
github expo / pound-random / pound-random-app / shared / KeyboardAccessory / index.js View on Github external
_pickImage = async () => {
    if (!(await this.permissionGuard())) return;

    let result = await ImagePicker.launchImageLibraryAsync({
      base64: true,
      quality: 0.25,
    });

    if (!result.cancelled) {
      this._setImage(result);
    }
  };