document-picker icon indicating copy to clipboard operation
document-picker copied to clipboard

type: types.pdf does not limit the selection

Open LJW123 opened this issue 1 year ago • 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', })

LJW123 avatar Mar 13 '24 01:03 LJW123

android 13

LJW123 avatar Mar 13 '24 01:03 LJW123

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

Thank you 🙂

vonovak avatar Mar 13 '24 07:03 vonovak

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.

https://github.com/react-native-documents/document-picker/assets/18021287/5340c4fb-3daf-4d22-a885-e5d35a6c3693

LJW123 avatar Mar 15 '24 01:03 LJW123

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?

LJW123 avatar Mar 15 '24 01:03 LJW123

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

vonovak avatar Mar 23 '24 21:03 vonovak