react-native-android-document-picker

1.0.7 • Public • Published

react-native-android-document-picker

Note: This library is Android specific.

Getting started

$ npm install react-native-android-document-picker --save

Mostly automatic installation

$ react-native link react-native-android-document-picker

Usage

import AndroidDocumentPicker from 'react-native-android-document-picker';

openDocument

AndroidDocumentPicker.openDocument({
    multipleFiles: boolean,
    fileTypes: object,
  },
  successCallback: Function,
  failureCallback: Function
);

openDocument usage

const handleChoosePhotoAndroid = async () => {
    let newFiles = [...files];

        await AndroidDocumentPicker.openDocument({multipleFiles: true, fileTypes: ["image/*"]}, (array) => {
          array.forEach((el) => {
            const doc = JSON.parse(el);
          
            console.log("doc:", doc);
            // {"fileName": "some_pdf_file.pdf", 
            // "fileSize": "450110", 
            // "fileType": "application/pdf", 
            // "fileUri": "content://com.android.providers.downloads.documents/document/1058"}
            
            newFiles.push({
            fileName: doc.fileName,
            uri: doc.fileUri,
            type: doc.fileType,
            size: doc.fileSize
            });
          });

          setFiles(newFiles);
        }, 
        (error) => {
            console.log('error', error);
        });

To-do

  • [ ] clean up iOS related folders
  • [ ] improve documentation

Package Sidebar

Install

npm i react-native-android-document-picker

Weekly Downloads

6

Version

1.0.7

License

MIT

Unpacked Size

528 kB

Total Files

91

Last publish

Collaborators

  • margaridaa