alexrintt / shared-storage

Flutter plugin to work with Android external storage.
http://alexrintt.io/shared-storage/
MIT License
53 stars 25 forks source link

When i try to getRealPathFromUri(directory_name), it shows me below error #55

Closed alexrintt closed 1 year ago

alexrintt commented 2 years ago

When i try to getRealPathFromUri(directory_name), it shows me below error

E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134): Failed to handle method call
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134): java.lang.UnsupportedOperationException: Unsupported Uri content://com.android.externalstorage.documents/tree/primary%3ADownload%2FDemo
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:174)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.content.ContentProviderProxy.query(ContentProviderNative.java:472)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.content.ContentResolver.query(ContentResolver.java:1183)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.content.ContentResolver.query(ContentResolver.java:1115)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.content.ContentResolver.query(ContentResolver.java:1071)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.lakscastro.sharedstorage.storageaccessframework.DocumentFileHelperApi.getDataColumn(DocumentFileHelperApi.kt:205)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.lakscastro.sharedstorage.storageaccessframework.DocumentFileHelperApi.getPath(DocumentFileHelperApi.kt:177)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.lakscastro.sharedstorage.storageaccessframework.DocumentFileHelperApi.getRealPathFromUri(DocumentFileHelperApi.kt:64)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.lakscastro.sharedstorage.storageaccessframework.DocumentFileHelperApi.onMethodCall(DocumentFileHelperApi.kt:56)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:320)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.os.Looper.loop(Looper.java:223)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#io.lakscastro.plugins/sharedstorage/documentfilehelper( 5134):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/flutter ( 5134): Exception while create new file: PlatformException(error, Unsupported Uri content://com.android.externalstorage.documents/tree/primary%3ADownload%2FDemo, null, java.lang.UnsupportedOperationException: Unsupported Uri content://com.android.externalstorage.documents/tree/primary%3ADownload%2FDemo

Originally posted by @manojSimfrom in https://github.com/lakscastro/shared-storage/issues/20#issuecomment-1141875793

manoj-simform commented 2 years ago

@lakscastro is there any update?

alexrintt commented 2 years ago

@manojSimfrom Hi! sorry the delay.

I'm working on #62 and some stuff have changed: about the getRealPathFromUri API, I noticed this function is a hard workaround to continue using the old File APIs even on the new Android versions, thus it will be removed soon in the next release v0.4.0.

But don't worry, you'll be able to do what you want even so. In order to do that, can you describe more your use case? What do you want to do with this function in a high-level perspective?

So I can create a new API that uses the new DocumentFile instead of relaying to workarounds like that and keep up-to-date with the latest Android privacy APIs.

alexrintt commented 1 year ago

Removing support for getRealPathFromUri.