3

I have no problem selecting one image at a time with allowsMultipleSelection: false. But with allowsMultipleSelection: true, it throws an error. Note: I do have allowsEditing: false.

What's happening

I get this error: "code":"ERR_INVALID_MEDIA_TYPE","message":"Cannot handle 'public.jpeg' media type" Not sure where 'public.jpeg' comes from as I am selecting, from my IPhone simulator (iOS 15.5), different types of pictures from different albums, and the error is the same for any picture I select. I do not have this error when allowsMultipleSelection: false.

Context:
React 18
Expo SDK 46
Expo-image-picker": "~13.3.1",
iOS 15.5 Iphone Simulator
Typescript: 4.8.2

Things I've tried

  • I ran expo doctorto check if dependencies problems but there are none.
  • Tried adding other options such as base64: true, different qualities, etc
  • Note: when I opened the node_modules folder, at expo-image-picker/plugin/tsconfig.json, this line was erroring: "extends": "expo-module-scripts/tsconfig.base" as the file was not found. So I manually installed expo-module-scripts and now the error is gone, with the line "extends": "expo-module-scripts/tsconfig.plugin" generated instead. The above did not change anything though - I get the same error on selecting multiple images (ERR_INVALID_MEDIA_TYPE).

Packages:

Minimal reproducible example

import React from 'react'
import { launchImageLibraryAsync, MediaTypeOptions } from 'expo-image-picker'
import { View, Button } from 'react-native'

export function GalleryImagesForm(props) {
  const pickImages = async () => {
    // No permissions request is necessary for launching the image library
    try {
      let result = await launchImageLibraryAsync({
        mediaTypes: MediaTypeOptions.All,
        allowsMultipleSelection: true,
      })

      console.log(result)
    } catch (error) {
      console.log(error)
    }
  }
  return (
    <View>
      <Button title="Pick an image from camera roll" onPress={pickImages} />
    </View>
  )
}
Nathalia
  • 46
  • 2
  • I just tested this and if you remove mediaTypes the error goes away. The only reason I can think of this happening is that jpeg an have .jpeg and .jpg as the file type and maybe `MediaTypeOptions.All` only covers one of those? – PhantomSpooks Sep 29 '22 at 13:00
  • Hey, thanks so much, that's interesting - I removed it and I still have the error, only, the extension on the error message changes: `Cannot handle 'public.jpeg' media type` to `Cannot handle 'public.png' media type` :/ (and different pictures pics have that message with their extension ) – Nathalia Sep 29 '22 at 13:09

0 Answers0