mdjfs / expo-image-multiple-picker

Fully customizable image picker for react native
https://npmjs.com/expo-image-multiple-picker
MIT License
21 stars 7 forks source link

Cannot use the returned URI when uploading the image to the server #9

Closed tonvlad88 closed 1 year ago

tonvlad88 commented 1 year ago

Hello @mdjfs,

I am new to react native and I did find your package (it was really awesome). Now, I tried to use the returned asset object to upload the selected images to the server but it seems it is not working well. Below is the sample return of the object after I selected one or more pictures in my gallery:

image

I used the uri.uri as my file in the formData but it will crash the app.

I have tried the expo-image-picker (sadly it only allows 1 image) and it gives me this different uri (see below) which allows me to upload the selected picture.

image

Do you have any idea about this? Hope you can share some time. Thank you

Device used: iPhone 7+

Screenshot: 315959774_818019415853049_7963799945899771162_n

An additional discussion here (not sure if it's related): https://forums.expo.dev/t/no-suitable-url-request-handler-found-for-ph-upload/60049/2

I also installed the mime package and get the type of the URI as mentioned here https://stackoverflow.com/questions/70337776/expo-sdk-43-no-suitable-url-request-handler-found-for-ph-upload but still got the error

mdjfs commented 1 year ago

Hi man! Thanks for the feedback!

I was looking the bug and i found some related issue (https://github.com/expo/expo/issues/15664) happens only in iOS, for some reason the uri starts in ph:// instead of file:// with the local uri of the file.

You can use the method getAssetInfoAsync from expo-media-library (https://docs.expo.dev/versions/latest/sdk/media-library/#medialibrarygetassetinfoasyncasset-options) and check if the localUri is the local uri of the file. Let me know if that works

tonvlad88 commented 1 year ago

Hi man! Thanks for the feedback!

I was looking the bug and i found some related issue (expo/expo#15664) happens only in iOS, for some reason the uri starts in ph:// instead of file:// with the local uri of the file.

You can use the method getAssetInfoAsync from expo-media-library (https://docs.expo.dev/versions/latest/sdk/media-library/#medialibrarygetassetinfoasyncasset-options) and check if the localUri is the local uri of the file. Let me know if that works

Thanks @mdjfs, using the localUri from expo-media-library resolved this issue. You can close this ticket. You are really awesome!