xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 505 forks source link

[Bug] [FilePicker] [Android] Exception is thrown when picking some files #1483

Closed IngweLand closed 4 years ago

IngweLand commented 4 years ago

Description

Java.IO.FileNotFoundException: File is virtual is thrown when pciking some files from Google drive. Not sure what are those virtual files exactly, but probably some file entities on Google Drive which have some dynamic content (just a pure guess).

Steps to Reproduce

  1. Have such "virtual file" on your google drive
  2. Try to pick it
  3. Call OpenReadAsync on FileResult

Expected Behavior

Either throw Net exception (and not a Java one) or pick the file (if it's possible to pick those virtual files at all).

Actual Behavior

Throws Java exception

Basic Information

vividos commented 4 years ago

How do you create a "virtual file"? And do you have a stack trace for us?

IngweLand commented 4 years ago

It feels like any document created on google drive and shared with you might be a virtual file

  1. Have 2 Google accounts, one of which is used on the testing device.
  2. Sign in into Google Drive with the second account, create Google document, and share it with viewer permission with your main account
  3. Pick that file on the device
IngweLand commented 4 years ago

Java.IO.FileNotFoundException: File is virtual: acc=3;doc=encoded=oX0eiSgeztRLkXJOtaCmP93xC/+3eZbLp1WycFZK1PDDSRi/98GX2Gj/ at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <42748fcc36b74733af2d9940a8f3cc8e>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <42748fcc36b74733af2d9940a8f3cc8e>:0 at Android.Content.ContentResolver.OpenInputStream (Android.Net.Uri uri) [0x00031] in <227a96d68a0440cea172be41b1306654>:0 at Xamarin.Essentials.FileBase.PlatformOpenReadAsync () [0x0001e] in D:\a\1\s\Xamarin.Essentials\FileSystem\FileSystem.android.cs:119 at Xamarin.Essentials.FileBase.OpenReadAsync () [0x00000] in D:\a\1\s\Xamarin.Essentials\FileSystem\FileSystem.shared.cs:105 at QQQ.uploadFile (Xamarin.Essentials.FileResult fileData) [0x001ee] in qqqqq.cs:554 --- End of managed Java.IO.FileNotFoundException stack trace --- java.io.FileNotFoundException: File is virtual: acc=3;doc=encoded=oX0eiSgeztRLkXJOtaCmP93xC/+3eZbLp1WycFZK1PDDSRi/98GX2Gj/ at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:151) at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:781) at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1983) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1798) at android.content.ContentResolver.openInputStream(ContentResolver.java:1475) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

IngweLand commented 4 years ago

https://stackoverflow.com/questions/46422736/how-to-open-inputstream-for-a-virtual-file-on-the-cloud

Stecpoint commented 4 years ago

We have the same problem. Is there a WA?

Stecpoint commented 4 years ago

https://stackoverflow.com/questions/46422736/how-to-open-inputstream-for-a-virtual-file-on-the-cloud

this methods can detect that file is virtual, but cant open stream for file.. Method for get virtual file return exception: Java.IO.FileNotFoundException: File is virtual. @IngweLand, how did you solve the problem? Did you manage to open the virtual file?

Stecpoint commented 4 years ago

for filter virtual files when create intent need add string: intent.AddCategory(Intent.CategoryOpenable);

this string disabled files, which can't loaded from other apps.