Closed ThinkDigitalSoftware closed 6 years ago
allowedFileExtensions
parameter does not filter files that are shown in the picker. I wasn't able to find an easy way to do that in Android. In iOS allowedUtiTypes
parameter could be used for that - then not wanted files will be disabled in the picker.
When file is picked its extension is checked using allowedFileExtensions parameter. Then file is copied to app temp directory. Copied file path is returned as result. If picked file extension is not in allowedFileExtensions list then extension_mismatch error is returned.
Oh.... How much control do you have over what shows up in the list?
Files can be filtered by MIME types in Android. I just released plugin v1.1.0 version where I added optional parameter allowedMimeType
. Previously */*
MIME type was used, now it becomes customisable.
As I understand you want to select files with custom extensions *.db
, yes? The closest MIME type that works for me is application/octet-stream
. Not all files will be filtered but for example it would not show images, videos, text files there.
In iOS you can register custom UTI type (instructions there).
Example:
FlutterDocumentPickerParams params = FlutterDocumentPickerParams(
allowedFileExtensions: ['db'],
allowedUtiTypes: ['your.domain.db'],
allowedMimeType: 'application/octet-stream',
);
final path = await FlutterDocumentPicker.openDocument(params: params);
Does allowedMimeType
parameter solve your problem?
It sounds like it will be closer to what I'm looking for. I'll try it out when I get on my computer again. Thank you! -- Think Digital 323-638-9448 760-678-8833 Facebook.com/ThinkDigitalRepair
It doesn't solve the problem, but it definitely helps. Could you also support a starting directory as well? Like, initialDirectory: "/sdcard"
?
_Sent from my Galaxy S9+ using FastHub
I found in documentation:
Callers can set a document URI through DocumentsContract.EXTRA_INITIAL_URI to indicate the initial location of documents navigator. System will do its best to launch the navigator in the specified document if it's a folder, or the folder that contains the specified document if not.
So it seems it is possible to set initial directory, at least in Android part. Need to check is it possible in iOS part.
Currently I have no plans to add this initial directory functionality to this plugin but PRs are welcome!
Ok, I'll see if I have a need in my app for it. But it seems like there could be a strong use case, for example if someone needs to find a download or if they want to start in the SD card always. If I need it, I'll try to submit a PR
I entered an
allowedFileExtension
in the params, but it didn't filter the list.