-
Notifications
You must be signed in to change notification settings - Fork 130
Different file paths returned depending on method of selection (Android 8) #44
Comments
Hi I've got the same problem. If fileChooser is used to open a file from downloads subfolder the subfolder is cut out. If I use the internal storage it works correctly. |
The same problem from @zigapeda the subfolder is been cut out from the result "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FTESTE%2FOutroNome.docx" Returns: |
Is there any workaround for subfolder issue? |
I haven't found anything yet for this.. The app in which I discovered this behaviour simply includes a note in the user feedback message to suggest using a different "file browser" if I've been working on other projects since then, so I haven't actually looked at this for a little while.. I still have a note of this in my backlog though, so when I get to this, if I do work out anything useful, I'll come post back here again. |
decodeURI(content://.../raw) worked for me before fetching the nativePath. |
I have vague recollections of trying that previously, but I just tested again now and it doesn't make any difference.. interestingly, we seem to be experiencing what seems to be the same issue in iOS now, but I haven't had a chance to dig any more into that side yet. |
FWIW: I've abandoned this route of importing files from the local device.. I've replaced feel free to do whatever you want with this issue report, I'll be unsubscribing from notifications after posting this. 👍 |
Came across this issue just now. |
@graphefruit This package is no longer actively maintained. PRs are of course welcome. |
I've just noticed something strange about picking files with the "file chooser" that this launches on Android 8..
in this scenario, I'm trying to import a JSON file that I've downloaded, so naturally it's currently sitting in my device's "Download" folder. when the file chooser opens, by default the left sidebar has the usual source options like "Images", "Videos", "Audio" and "Recent". after this it shows "Downloads" and "Documents" before listing other apps that can be used to choose a file.
if I close this sidebar and open the kebab menu in the top right corner, I have an option to "Show internal storage". after this, I now see another option below "Documents" that lists my device's name, providing access to my device internal storage. in this route, I simply open the "Download" folder and I see the exact same files as the "Downloads" shortcut in the sidebar.
this is where things get interesting... I put some
console.log
calls at key points to see what was going on, thereby ending up with the following code:as for the different ways of choosing the file, this is what I discovered:
when selected via "Downloads" sidebar shortcut:
fileChooser.open() result: "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fcustom-folder%2Fmy-custom-file.json"
filePath.resolveNativePath(uri) result: "file:///storage/emulated/0/Download/my-custom-file.json"
about to call readAsText() with: "file:///storage/emulated/0/Download" "my-custom-file.json
when selected via "browse internal storage":
fileChooser.open() result: "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fcustom-folder%2Fmy-custom-file.json"
filePath.resolveNativePath(uri) result: "file:///storage/emulated/0/Download/custom-folder/my-custom-file.json"
about to call readAsText() with: "file:///storage/emulated/0/Download/custom-folder" "my-custom-file.json
from what I can see, the path is fine up to the point that I use
cordova-plugin-filepath
toresolveNativePath()
.. so is this a bug in this plugin or am I simply misunderstanding something here?The text was updated successfully, but these errors were encountered: