Hello guys I guess some of you already got in this issue. I am wonder if there is a way to select multiple files using Expo Document Picker or I just need to select them one by one which obviously is not a good way for the user.

For now all I have is this

_selectAndUpload = async document => {
    try {
      const picked = await DocumentPicker.getDocumentAsync({
        type: "*/*",
        copyToCacheDirectory: true
      });
      if (picked.type === "cancel") {
        return;
      } else if (picked.type === "success") {
        const { name } = picked;
        const fileUri = `${FileSystem.documentDirectory}${name}`;
        if (Platform.OS === "ios") {
          const pickerResult = await FileSystem.downloadAsync(
            picked.uri,
            fileUri
          );
          this.handleDocumentPicked(pickerResult, document);
        } else {
          const pickerResult = {
            name: picked.name,
            uri: picked.uri
          };
          this.handleDocumentPicked(pickerResult, document);
        }
      } else {
        return;
      }
    } catch (error) {
      this.setState({
        success: false,
        successModVisible: true,
        successLineText: `We can't support this file.!`
      });
    }
  };

0 Answers