Comments (20)
Hi, That is not possible unless you set OpenFileDialogParams.copyFileToCacheDir
to true. Picked file may locate e.g. on Google Drive or on other storage provider so "absolute path" is not available. If you have different information please reopen with more details.
from flutter_file_dialog.
It seem that the absolute_path plugin can retrieve this information
from flutter_file_dialog.
It seems to copy the file to a cache dir at least in some cases. What is your use case, why do you need this?
from flutter_file_dialog.
We are working on elrepo.io, this is related to #12 .
The use case is we share on our "F2F backend" a file: the user select a file, and this filepath is passed to our backend to share it over the f2f network. This backend, called RetroShare, don't understand Android Uri scheme, so we have to pass the absolute file path.
We don't want to create a cached file to do not waste phone space, we want to access directly to the file.
from flutter_file_dialog.
Have you tried using that other plugin, does it give you the path you need?
If user picks a file e.g. from Google Drive, is the file physically present on user's device yet? If not, you cannot have an absolute path to it? Or are you expecting to get a file URL pointing to the file at Google Drive?
And even if you have an absolute path to a file located on user's device, have you tested that you can access the file in Android using the absolute file path? I think there might be some OS restrictions which prevent you from accessing the file with an absolute path (especially in the latest Android versions).
from flutter_file_dialog.
Hi,
We need the local path, what mean that we only want to pick local files. If we create params like:
final params = fileDialog.OpenFileDialogParams(
localOnly: true,
copyFileToCacheDir: false
);
The localOnly
option is supposed to return local files only right? So we can have the absolute path from them, isn't it?
from flutter_file_dialog.
As commented here, the plugin flutter_absolute_path: ^1.0.6
makes our app crash without error message.
from flutter_file_dialog.
Hi,
Just to know, the option localOnly: true
should return only local files (not those on the cloud)?
Thanks
from flutter_file_dialog.
Yes it should return local files only.
from flutter_file_dialog.
So setting localOnly: true
with copyFileToCacheDir: false
could return the absolute path. Are you going to support this? Otherwise I have to find another way to retrieve the absolute path.
Thanks in advance!
from flutter_file_dialog.
So what do you do with the absolute path? Do you want to for example read the file? Have you tested that reading a file with an absolute path is possible or does Android security features prevent it?
It could be supported if the absolute path is really useful, but only in that case. But I have not investigated is it possible to get the absolute path and how is it done. I am quite busy so I recommend a PR if possible.
from flutter_file_dialog.
So what do you do with the absolute path?
Read the file from the file system to share it in our app. As is an application to share content, we don't want to create a copy on the file system because the devices have a limited storage.
Have you tested that reading a file with an absolute path is possible or does Android security features prevent it?
On Android 10/Q if you add y the following lines you can read the file from the storage:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:requestLegacyExternalStorage="true"
>
What do you think if I write a PR where, if localOnly: true
and copyFileToCacheDir: false
return the absolute path?
from flutter_file_dialog.
Thanks for the details. Then it makes sense. Please write a PR.
from flutter_file_dialog.
Hi,
Get absolute filepath on Android / AndroidX is not trivial.
We can add this code to the app.
But I don't know why, I can't let it work inside this plugin. Maybe you can ask me something:
The parameter this.context
passed here, in the FlutterAbsolutePathPlugin
, is the same kind of context that the passed here, in the flutter_file_dialog
plugin (this).
From FlutterAbsolutePathPlugin
is the context passed to the plugin when instantiated.
From flutter_file_dialog
is of type Activity
, declared here.
As we need the context to get the absolute file path maybe this "context type" matter, because I get an error when used here.
I-m not Android developer and I'm not sure about the difference.
from flutter_file_dialog.
For some reason when I'm trying to adapt the code of FlutterAbsolutePathPlugin
, at the time it call the cursor to get the absolute path, it doesn't work on the flutter_file_dialog
.
On the line linked above, you will see the instantiation of the cursor, witch return, for the same hardcoded URI, in the FlutterAbsolutePathPlugin
:
context
type equals to io.flutter.app.FlutterApplication
cursor!!.moveToFirst()
is TRUE
cursor!!.getCount()
is 1
Instead, the same kotlin class, imported on the flutter_file_dialog
, witch we send the same context as marked here, return:
context
type equals to android.app.Application
cursor!!.moveToFirst()
is FALSE
cursor!!.getCount()
is 0
So I suppose that the problem is how the context instantiate the cursor, maybe we are not using the correct context.
If you have any ideas of how to fix this, I could write the code. BTW I'm going to combine the two plugins
from flutter_file_dialog.
I don't have quickly any ideas what is wrong. Please read the Flutter docs for implementing a Flutter plugin if not read yet.
Actually this looks too much like a hack to be included in this plugin after all, so I suggest you implement a separate plugin for this. I can try to help you there if needed. Can you take an URL from this plugin and convert it to an absolute path using the other plugin?
from flutter_file_dialog.
Hi,
I created a fork trying to integrate both plugins. Take a look that I hardcoded the uri path here:
Also if you want take a look at this comment to see where I am:
https://gitlab.com/elRepo.io/elRepo.io-android/-/issues/40#note_620591573
from flutter_file_dialog.
I opened a stackoverflow question
from flutter_file_dialog.
After clean the code and migrate it properly to Android embedding V2, I let absolute file path plugin working.
I suggest to combine the two plugins to get the absolute path.
BTW, I think the problem merging the two plugins was something related of how this plugin get the activity context. If needed, we can try to merge it on the future, but for the moment, getting absolute path from here is not needed.
Those who need the absolute path, try this PR of the flutter absolute path plugin where I accomplish it with AndroidX and Flutter embedding V2.
KasemJaffer/flutter_absolute_path#15
Thanks for the attention
from flutter_file_dialog.
Great to hear you found a fix! I could take a closer look at your code when I have time. If it doesn't add too much complexity to this plugin, merging the code here could make sense.
from flutter_file_dialog.
Related Issues (20)
- Wrong return path on not choosing folder HOT 1
- Missing file with building for ios
- in ios cant load csv txt xls HOT 1
- build issue in flutter master HOT 1
- Saving file does not overwrite existing unless selected HOT 4
- Extra content being saved to end of file sometimes HOT 6
- Implemented get absolute path for Android using PickiT library HOT 1
- Fatal Exception: java.lang.IllegalStateException Reply already submitted HOT 4
- File dialog now image only? HOT 1
- [bug][invalid_file_extension] Set file extension filter when picking a document.
- Android: Only download or recent available as targets for save HOT 5
- Android: path is incomplete after saveFile HOT 4
- If file already exist then the newly saved file gets renamed after file extension HOT 1
- [Bug]: MissingPluginException (MissingPluginException(No implementation found for method saveFile on channel flutter_file_dialog)) HOT 1
- Support for Windows ?
- Saving file with overwrite makes file unreadable by android OS
- DirectoryLocation custom class HOT 1
- pub.dev release HOT 1
- save multiple File
- No implementation found for method saveFile on channel flutter_file_dialog HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_file_dialog.