fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
920 stars 517 forks source link

Issue while Opening the file #967

Open Ashwin1002 opened 4 months ago

Ashwin1002 commented 4 months ago

When Opening the file throws error. java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.example.example/cache/SubaruOutbackOnStreetAndDirt.mp4

The, directory where the file exist is only "data/com.example.example/cache/SubaruOutbackOnStreetAndDirt.mp4" but when opening the file it prints extra "data" in the path

*To Reproduce

await FlutterDownloader.open(taskId: taskID)

Steps to reproduce the behavior:

  1. Use FlutterDownloader.open(taskId: '$String') method

Expected behavior Should open the existed file, but throws exception.

Log

The full log is :

E/MethodChannel#vn.hunghd/downloader( 4630): Failed to handle method call E/MethodChannel#vn.hunghd/downloader( 4630): java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.example.example/cache/SubaruOutbackOnStreetAndDirt.mp4 E/MethodChannel#vn.hunghd/downloader( 4630): at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:825) E/MethodChannel#vn.hunghd/downloader( 4630): at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:450) E/MethodChannel#vn.hunghd/downloader( 4630): at vn.hunghd.flutterdownloader.IntentUtils.buildIntent(IntentUtils.kt:19) E/MethodChannel#vn.hunghd/downloader( 4630): at vn.hunghd.flutterdownloader.IntentUtils.validatedFileIntent(IntentUtils.kt:36) E/MethodChannel#vn.hunghd/downloader( 4630): at vn.hunghd.flutterdownloader.FlutterDownloaderPlugin.open(FlutterDownloaderPlugin.kt:369) E/MethodChannel#vn.hunghd/downloader( 4630): at vn.hunghd.flutterdownloader.FlutterDownloaderPlugin.onMethodCall(FlutterDownloaderPlugin.kt:66) E/MethodChannel#vn.hunghd/downloader( 4630): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) E/MethodChannel#vn.hunghd/downloader( 4630): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292) E/MethodChannel#vn.hunghd/downloader( 4630): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) E/MethodChannel#vn.hunghd/downloader( 4630): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#vn.hunghd/downloader( 4630): at android.os.Handler.handleCallback(Handler.java:959) E/MethodChannel#vn.hunghd/downloader( 4630): at android.os.Handler.dispatchMessage(Handler.java:100) E/MethodChannel#vn.hunghd/downloader( 4630): at android.os.Looper.loopOnce(Looper.java:232) E/MethodChannel#vn.hunghd/downloader( 4630): at android.os.Looper.loop(Looper.java:317) E/MethodChannel#vn.hunghd/downloader( 4630): at android.app.ActivityThread.main(ActivityThread.java:8674) E/MethodChannel#vn.hunghd/downloader( 4630): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#vn.hunghd/downloader( 4630): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) E/MethodChannel#vn.hunghd/downloader( 4630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) I/flutter ( 4630): Failed to open downloaded file. Reason: Failed to find configured root that contains /data/data/com.example.example/cache/SubaruOutbackOnStreetAndDirt.mp4

nafiskabbo commented 4 months ago

I have the same issue. Any solution?

Ashwin1002 commented 4 months ago

For current fix, I am using open_filex package. To get the file path, i have saved the absolute path of the directory and get the file name from the url and used it to open the file only on Android.