react-native - 如何正确使用 Expo.DocumentPicker.getDocumentAsync。 [博览会] [ReactNative]

标签 react-native expo

我试图限制可以由 Expo.DocumentPicker.getDocumentAsync 选择的文件类型,但没有成功。

如何一次过滤多个 mimeType?

我已经尝试如下:

Expo.DocumentPicker.getDocumentAsync({type: "image/*;application/pdf"});


Expo.DocumentPicker.getDocumentAsync({type: "image/*,application/pdf"});


Expo.DocumentPicker.getDocumentAsync({type: ["image/*","application/pdf"]}); //CRASH

我正在使用 sdk 27​​.0.0。

一些建议?世博队? :}

引用:
https://docs.expo.io/versions/latest/sdk/document-picker#type-string----the-mime-type-of

最佳答案

目前,我们似乎无法在 expo 的文档选择器上传递多个 mime 类型,因为它是字符串类型而不是数组。还有一个关于相同的未决问题 here
我尝试使用以下任何一种 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
    });
对于其他 MIME 类型,请查看 this

关于react-native - 如何正确使用 Expo.DocumentPicker.getDocumentAsync。 [博览会] [ReactNative],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50108496/

相关文章:

xcode - 如何将EXPO项目弹出到 native 代码

ios - 如何在 View Controller 中使用 RCTRootView?

javascript - 如何为所有选项卡设置相同的背景图片? ( react native )

react-native - npm install -g expo-cli 未完成安装

react-native - 为什么 tabBarIcon 无法导航到 Tab.Screen 中的组件?

ios - 如何修复 Xcode 中的错误 React Native 'UMCore' 构建错误

ios - react native 错误 - react-native-xcode.sh : line 45: react-native: command not found Command/bin/sh failed with exit code 127

react-native - 如何使用 Expo 清理(重置缓存)React Native。不确定是否是缓存问题

javascript - React Navigation 5 真的很慢并且在 Expo 上丢掉了 JS FPS

javascript - react native : Touchable Opacity element is clickable on iOS but not Android