react-native-documents / document-picker

Document Picker for React Native
https://react-native-documents.github.io/
MIT License
1.35k stars 437 forks source link

How to pick only JSON files in iOS? #575

Closed pigpudle closed 1 year ago

pigpudle commented 2 years ago

Question

Hi! I'd wanted to allow to pick only files with .json extension. How to achieve that? I haven't found a JSON file here as mentioned in the docs. I also tried to set json type for options, but this leads to all files to be greyed out. Thanks.

drpiou commented 2 years ago

Hello!

In a general way, I also need to pick files based on the extension rather that the mime type (especially because of Apple mime types), or at least a less generic mime types coming from apple like "mime-db".

In my project, I need to select text files but only ".txt", ignoring ".php" and all other "public.plain-text" files that Apple sees.

Right now, I need to do a check after the file has been selected and prompt to the user that the extension is not valid (for our system), and it leads to un-comprehensive behaviour from the app to the user (for the user, why ".php" files where not grayed out while ".mp4" were?).

ignaciosantise commented 1 year ago

@pigpudle try setting type as public.json for iOS.

I've found newer documentation about type identifiers in Apple: https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared_uniform_type_identifiers

vonovak commented 1 year ago

Hello, closing as answered,

thank you