-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returned path string of saveFile() on Android does not resolve to the actual selected file path #1553
Comments
This issue is stale because it has been open for 7 days with no activity. |
Anyone an idea or the time to solve this? |
This issue is stale because it has been open for 7 days with no activity. |
I am also seeing this issue, where regardless of the path selected the return value using the .save() function is always /storage/emulated/0/Downloads/. interestingly, if you pass through the bytes argument to the save() it does right to an existing file, however it will not if the file size is more than the bytes you are trying to write (i.e. if content was removed from the file) edit: Opened a separate issue for the second half of this #1569 |
This issue is stale because it has been open for 7 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
if there is no easy way to solve it, how to use |
Describe the bug
When using the saveFile() method of the file picker, the given file data is correctly saved to the device storage, but the returned string path is a completely different one. This way it is not possible to do any additional tasks on the written file (in our case some data validation - other tasks, like save the file path in a local data base for later use, is also possible).
Platform
Platform OS version
Android SDK 33 - tested on SUNMI D3 MINI (Real-Device), Emulator
iOS ?
How are you picking?
Details to reproduce the issue
Use the code above
Flutter Version details
Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3880], locale de-DE)
• Flutter version 3.19.6 on channel stable at C:\Tools\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (3 months ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1
Additional context
flutter_file_picker v. 8.0.5
As I further investigated the code and the pull request, that added the saveFile() functionality on mobile, it seems that the returned path is constructed using the environment's download directory (line 91) and just adds the file name retrieved from the data uri. But to write the data to the file, the entire uri seems to be used in the outputStream (line 94).
flutter_file_picker/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java
Lines 91 to 100 in 5ee4805
As I am relatively new to Flutter (less than a year of experience on this topic) and even less on Android java/kotlin I unfortunately don't know a possible solution. Maybe it is possible to use additional information of the uri in some way to resolve a functioning path. Thanks in advance for the support and thank you for providing this otherwise cool package.
The text was updated successfully, but these errors were encountered: