Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰] Error processing request body: Could not find image file #2119

Open
dmsierra11 opened this issue Apr 21, 2023 · 27 comments
Open

[馃悰] Error processing request body: Could not find image file #2119

dmsierra11 opened this issue Apr 21, 2023 · 27 comments

Comments

@dmsierra11
Copy link

dmsierra11 commented Apr 21, 2023

Description

Error when trying to upload image from gallery

Simulator Screen Shot - iPhone 12 - 2023-04-20 at 13 10 32

Running the example app of this repo gives me the same issue:

Simulator.Screen.Recording.-.iPhone.14.-.2023-04-21.at.09.42.45.mp4

How to repeat issue and example

const imagePickerDefaultOptions = {
  selectionLimit: 0,
  mediaType: 'photo' as MediaType,
  includeBase64: false,
  includeExtra: true,
};

launchImageLibrary(imagePickerDefaultOptions, (imgPickerResponse) => {
    if (imgPickerResponse.assets?.[0]) {
      onPhotoTaken(imgPickerResponse.assets?.[0]);
    }
  });

Solution

What needs to be done to address this issue?

Additional Information

  • Image Picker version: >=4.10.3
  • React Native version: 0.66.1 and 0.71.2
  • Platform: iOS
  • Development Operating System: MacOS
  • Dev tools: Xcode 14.0.1, iOS 16.0
@yorickshan
Copy link

same issue

1 similar comment
@VanDinh18
Copy link

same issue

@cokron
Copy link

cokron commented Apr 24, 2023

Same here - upgraded from react-native-image-picker 4.10.3 to 5.3.1.
It used to work in 4.10.3 both in Simulator and on real device (iPhone).
Now it stopped working. Going back to 4.10.3 for now.

@jeremiahlachica
Copy link

I also have the same issue. Currently using 5.3.1

@maydersonmellops
Copy link

maydersonmellops commented Apr 28, 2023

Same error here, until this correction was made, I used lib react-native-image-crop-picker and implemented it as follows:

import ImageCropPicke from 'react-native-image-crop-picker';

ImageCropPicker.openPicker({
  mediaType: 'photo',
  cropping: false
})
   .then(data => console.log(data))
   .catch(error => console.log(error));

Had a similar result to Image Picker.

@maydersonmellops
Copy link

@dmsierra11 I believe the problem is here.

Successfully selected image:

{
  "fileName":"5693202E-E952-4C0D-A69B-2FF9B0F6C688.jpg",
  "fileSize":993045,
  "height":2500,
  "type":"image/jpg",
  "uri":"file:///Users/mayderson/Library/Developer/CoreSimulator/Devices/D555E641-C03B-407D-9251-28DBEF5BFEE6/data/Containers/Data/Application/D641C420-4AE4-49AB-A63B-5B05E88F59D7/tmp/5693202E-E952-4C0D-A69B-2FF9B0F6C688.jpg",
  "width":1668
}

Error selected image:

{
  "fileName":"B22A70A5-D144-4857-8249-97C1FDB3FAE1.jpg",
  "height":0,
  "type":"image/jpg",
  "uri":"file:///Users/mayderson/Library/Developer/CoreSimulator/Devices/D555E641-C03B-407D-9251-28DBEF5BFEE6/data/Containers/Data/Application/D641C420-4AE4-49AB-A63B-5B05E88F59D7/tmp/B22A70A5-D144-4857-8249-97C1FDB3FAE1.jpg",
  "width":0
}

In other words, the height and width attributes are coming with 0 and the fileSize is not coming, which is causing this problem.

@dmsierra11
Copy link
Author

Thank you @maydersonmellops, I also noticed the 0 values on height and width, it looks like there is an error selecting the image from the library, only instead of giving an error on that part of the process it just gives the image path with these 0 values. Do you have any idea how to fix it? I hope the maintainer of this repo can give us some light on how to fix it. Meanwhile I will also try your suggestion and change to react-native-image-crop-picker

@dmsierra11
Copy link
Author

@cokron it happens to me on 4.10.3 too, unfortunately.

@dmsierra11
Copy link
Author

@maydersonmellops it actually happens the same to me with react-native-image-crop-picker

@bcgilliom
Copy link

Seems to only happen for me on the sim flower image (the one picked in the video above), which is marked as HDR and has image type of HEIC when viewed in the photos app

@minh-dai
Copy link

minh-dai commented Jun 7, 2023

+1

@dmsierra11
Copy link
Author

dmsierra11 commented Jun 7, 2023

Yes @bcgilliom, you are totally right, it happens to me only on this picture too. I just don鈥檛 know why. FYI I tried with a different HEIC image and it worked.

@blyszcz
Copy link

blyszcz commented Jun 7, 2023

I had a similar encounter with a captivating sunflower image. If anyone else has experienced this issue with different images, I would greatly appreciate it if you could kindly share your observations.

@alizaib1217
Copy link

I had a similar encounter with a captivating sunflower image. If anyone else has experienced this issue with different images, I would greatly appreciate it if you could kindly share your observations.

I had the same issue I believe its crashing for the image which are not available like the one that are on cloud. Once the cloud image is downloaded it does not crash.

@andresmejia3
Copy link

Is there any solution to this yet?

@andresmejia3
Copy link

Or any workaround?

@Acetyld
Copy link

Acetyld commented Jul 6, 2023

Any work around?

@vksgautam1986
Copy link

3.6.0 is working fine but its quite older version

@jakobpesch
Copy link

Also happens in 5.4.0.

@NikitaRadzkov
Copy link

Also happens in 5.4.2

@dflm25
Copy link

dflm25 commented Aug 25, 2023

Hello same issue, Working with "react-native-image-picker": "^4.10.3",
Screenshot 2023-08-25 at 6 10 44 PM

@NiharR27
Copy link

same issue on "react-native-image-picker": "^7.0.0",

@andresmejia3
Copy link

same issue on "react-native-image-picker": "^7.0.0",

Use react-native-image-crop-picker

@DusanSpasojevic98
Copy link

I had a similar encounter with a captivating sunflower image. If anyone else has experienced this issue with different images, I would greatly appreciate it if you could kindly share your observations.

I had the same issue I believe its crashing for the image which are not available like the one that are on cloud. Once the cloud image is downloaded it does not crash.

@alizaib1217 Is there any way to don't show cloud images or to download them when picked, or any other solution?

@pnadj
Copy link

pnadj commented Oct 22, 2023

Same issue in 7.0.1

@samcodefish
Copy link

samcodefish commented Nov 9, 2023

I have created a PR that hopefully fixes this issue. Any testing / feedback would be helpful.

@JB712
Copy link

JB712 commented Dec 8, 2023

Looking at @samcodefish PR and from my understanding of the problem, it seems that .heic files cannot be handled like .jpg files. When selecting a .heic file, the copy that you can access from launchImageLibrary response is a .jpg file (at least it is what I find in uri property) and that is why height, width, type and fileSize are wrong and you can't access it.

Unfortunately, your PR does not correct this behavior, I still got uri to a .jpg file that result in a bug ("Could not find image ...")

I just want to add that to get to this conclusion, I only used the .heic image from the iPhone 12 mini - iOS 16.2 emulator, the one that display flowers. Maybe it is different with a real device or with different images

EDIT:
It seems that

It's a known issue that the red flower image can't be selected using the simulator

I tried with an other heic file and it works fine (on simulator). Thanks Apple I guess 馃槖

(source https://developer.apple.com/forums/thread/699155?answerId=702819022#702819022)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests