我试图限制可以由 Expo.DocumentPicker.getDocumentAsync 选择的文件类型,但没有成功。
如何一次过滤多个 mimeType?
我已经尝试如下:
Expo.DocumentPicker.getDocumentAsync({type: "image/*;application/pdf"});
Run Code Online (Sandbox Code Playgroud)
和
Expo.DocumentPicker.getDocumentAsync({type: "image/*,application/pdf"});
Run Code Online (Sandbox Code Playgroud)
和
Expo.DocumentPicker.getDocumentAsync({type: ["image/*","application/pdf"]}); //CRASH
Run Code Online (Sandbox Code Playgroud)
我正在使用 sdk 27.0.0。
一些建议?世博队?:}
参考:https : //docs.expo.io/versions/latest/sdk/document-picker#type-string----the-mime-type-of
目前,我们似乎无法在 expo 的文档选择器上传递多种 mime 类型,因为它是字符串类型而不是数组。这里还有一个与此相关的未决问题
我尝试使用以下任意一种 MIME 类型来实现与此类似的操作,以仅上传某些文件类型:
let result = await DocumentPicker.getDocumentAsync({
type: "*/*" // all files
// type: "image/*" // all images files
// type: "audio/*" // all audio files
// type: "application/*" // for pdf, doc and docx
// type: "application/pdf" // .pdf
// type: "application/msword" // .doc
// type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" // .docx
// type: "vnd.ms-excel" // .xls
// type: "vnd.openxmlformats-officedocument.spreadsheetml.sheet" // .xlsx
// type: "text/csv" // .csv
});
Run Code Online (Sandbox Code Playgroud)
对于其他 MIME 类型,请查看此