jfversluis / FilePicker-Plugin-for-Xamarin-and-Windows

FilePicker Plugin for Xamarin and Windows
MIT License
157 stars 80 forks source link

Added condition to stop path conversion on android #195

Closed jlucaspains closed 4 years ago

jlucaspains commented 4 years ago

Description of Change

On Android Q (10) the File Path returned on a file pick may refer to an external location like the Downloads folder. Upon trying to read the file, a System.UnauthorizedAccessException is thrown. This change will use the original content URI and content resolver to load the file instead of File.OpenRead.

Issues Resolved

Platforms Affected

vividos commented 4 years ago

Thanks for the contribution. I liked your first commit better, since it skips calling IOUtil.GetPath() altogether. And could you please add a comment why the URI isn't tried to be resolved on Android Q and later? Doesn't need to be much text... Thanks!

jlucaspains commented 4 years ago

Easy! I will do it later today and push another commit.

vividos commented 4 years ago

@jfversluis Looks good to me, I think you can merge this. Couldn't actually test, since I'm on vacation.

jfversluis commented 4 years ago

Beta version is here: https://www.nuget.org/packages/Xamarin.Plugin.FilePicker/2.1.44-beta

Let me know how it goes

jlucaspains commented 4 years ago

I just tried with the packaged version and it worked well in my project. Perhaps @IngweLand can test it as well?