react-native-documents/document-picker

type: types.pdf does not limit the selection

Opened this issue · 5 comments

Although I set it to PDF, I can still select files of any format. However, if I set it to images, only photos can be selected.

DocumentPicker.pick({
allowMultiSelection: false,
presentationStyle: 'fullScreen',
type: types.pdf,
copyTo: 'documentDirectory',
})

android 13

Hello and thanks for reporting,
can you share a video? What document provider did you use to select documents?

Thank you 🙂

Thank you, I understand now;

it's a problem with the document provider.
When I use a Xiaomi phone (Android 13) and choose files using the system's file manager, I can only select PDFs. However, when I use a document provider from another app (like QQ, a popular instant messaging app in China), I can select files of any type.
When using a Huawei phone (HarmonyOS 2.0.1, and I cannot see the supported Android version), all document providers (including the system's own) allow me to select files of any format.

Screenrecorder-2024-03-15-09-36-59-350.mp4

Is there no solution to this issue? Since third-party document providers do not restrict file types, there's nothing we can do. If it's unsolvable, can I limit which document providers can be used? For example, can I restrict users to only select files from the system's document provider and not from third-party document providers?

Hello,
I'm sorry you have this issue but I don't think there's a way to fix it. The only thing you can do is handle this situation inside of your application and display an error in this case.
You can use the hasRequestedType field in the response (only available in the module for sponsors), see docs