[Web] launchImageLibraryAsync with allowsMultipleSelection=true does not work

Please provide the following:

  1. SDK Version: 36
  2. Platforms(Android/iOS/web/all): all

I am working with expo SDK36 and I have read the documentation for imagelibrary from A to Z.

This is how I use launchImageLibraryAsync:

  const _onAddImagePressed = async (values) => {
    draftUpdate(values);
    if (Platform.OS !== 'web') {
      const { getCameraRollAsync } = require('../../../core/camera/utils');
      // import { getCameraAsync, getCameraRollAsync } from '../../../core/camera/utils';
      await getCameraRollAsync();
    }

    const options = {
      height: '300px',
      width: '300px',
      allowsEditing: true, // ios (crop) & android (crop/rotate) only
      allowsMultipleSelection: true, // web only
      base64: true,
      quality: 0.5,
    };
    try {
      const { base64, height, width, uri, cancelled, ...rest } = await launchImageLibraryAsync(options);
      console.log({
        base64: base64 ? base64.slice(0, 30) : base64,
        height,
        width,
        uri: uri.length > 100 ? uri.slice(0, 30) : uri,
        cancelled,
        rest,
      });
    } catch (e) {
      alert('something went wrong while processing camera roll');
    }
  };

This is getCameraRollasync:

export async function getCameraRollAsync() {
  // permissions returns only for location permissions on iOS and under certain conditions, see Permissions.LOCATION
  const { status /* , permissions */ } = await askAsync(CAMERA_ROLL);
  console.log(status);
  if (status === 'granted') {
    return getCameraRollPermissionsAsync();
  }
  throw new Error('Camera roll permission not granted');
}
  1. For some reason, the permissions does not work on the web, so I only ask them for natrive , otherwise I get Uncaught (in promise) Error: Camera roll permission not granted
  2. The return of launchImageLibraryAsync(options) look like:

{base64: undefined, height: 0, width: 0, uri: “data:image/jpeg;base64,/9j/4f/”, cancelled: false, …}

I tried to split the base64 to see if it contains all the list with console.log(base64.split('base64')); but that is not the case.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.