How to use the react-native-document-picker.DocumentPicker.show function in react-native-document-picker

To help you get started, we’ve selected a few react-native-document-picker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cometchat-pro-samples / react-native-chat-app / chatApp / src / ChatScreen.js View on Github external
documentPicker(){
        DocumentPicker.show({
            filetype: [DocumentPickerUtil.allFiles()],
        },(error,response) => {
            if(Platform.OS === 'ios'){
                var ext = response.fileName.split('.')[1].toLowerCase();               
                var type = this.getMimeType(ext);
            }
            var file = {
                name: response.fileName,
                type: Platform.OS === "android" ? response.type : type, 
                uri: Platform.OS === "android" ? response.uri : response.uri.replace("file://",""),
            }
            this.setState({ mediaMsg: file });
        });
    }
github cometchat-pro-samples / react-native-chat-app / chatApp / src / GroupChatScreen.js View on Github external
documentPicker(){
        DocumentPicker.show({
            filetype: [DocumentPickerUtil.allFiles()],
        },(error,response) => {
            if(Platform.OS === 'ios'){
                var ext = response.fileName.split('.')[1].toLowerCase();               
                var type = this.getMimeType(ext);
            }
            var file = {
                name: response.fileName,
                type: Platform.OS === "android" ? response.type : type, 
                uri: Platform.OS === "android" ? response.uri : response.uri.replace("file://",""),
            }
            this.setState({ mediaMsg: file });
        });
    }
github lbryio / lbry-android / app / src / page / publish / view.js View on Github external
handleUploadPressed = () => {
    DocumentPicker.show(
      {
        filetype: [DocumentPickerUtil.allFiles()],
      },
      (error, res) => {
        if (!error) {
          //console.log(res);
        }
      }
    );
  };
github sovrin-foundation / connector-app / app / restore / restore.js View on Github external
restoreBackup = () => {
    DocumentPicker.show(
      {
        filetype: [
          Platform.OS === 'android' ? 'application/zip' : 'public.zip-archive',
        ],
      },
      (error, res) => {
        if (res) {
          this.props.saveFileToAppDirectory(res)
        } else {
          //TODO handle else
          console.log('err', error)
        }
      }
    )
  }
github mockingbot / react-native-zip-archive / example / Example.js View on Github external
browseFiles () {
    DocumentPicker.show({
      filetype: [(Platform.OS === 'android') ? '*/*' : 'public.data']
    }, (err, response) => {
      if (err) {
        console.error(err)
      }
      const fileDetails = {
        uri: response.uri,
        name: response.fileName,
        size: response.fileSize,
        type: response.type
      }
      this.setState({
        ...this.state,
        fileDetails: fileDetails
      })
    })
github anchetaWern / RNChatkitDemo / src / screens / Chat.js View on Github external
openFilePicker = async () => {
    await this.setState({
      is_picking_file: true
    });

    DocumentPicker.show({
      filetype: [DocumentPickerUtil.allFiles()],
    }, async (err, file) => {
      if (!err) {

        try {
          const file_type = mime.contentType(file.fileName);
          const base64 = await RNFS.readFile(file.uri, "base64");

          const file_blob = await Blob.build(base64, { type: `${file_type};BASE64` });

          this.attachment = {
            file_blob: file_blob,
            file_name: file.fileName,
            file_type: file_type
          };