# rn-file-picker-android

<a href="https://https://github.com/Margaridaa/rn-file-picker-android/pulls" target="_blank">
<img  src="https://img.shields.io/badge/PRs-welcome-green?color=blue"/>
</a>
<a href="https://www.npmjs.com/package/rn-file-picker-android" target="_blank">
<img src="https://img.shields.io/npm/v/rn-file-picker-android?color=violet"/>
</a>

#### **Note**: This library is Android specific.

## Getting started

`$ npm install rn-file-picker-android --save`

### Mostly automatic installation

`$ react-native link rn-file-picker-android`

## Usage
```javascript
import AndroidDocumentPicker from 'rn-file-picker-android';
```

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

#### openDocument usage
```javascript
const handleChoosePhotoAndroid = async () => {
    await AndroidDocumentPicker.openDocument({multipleFiles: false, fileTypes: ["application/pdf", "image/*"]},
      (documents: any) => {
        documents.forEach((el: any) => {
          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"}
          
          documentsAux.push({
           fileName: doc.fileName,
           uri: doc.fileUri,
           type: doc.fileType,
          });
        });
      },
      (error: any) => {
        console.log('error', error);
      });
```

#### To-do
- [x] clean up iOS related folders
- [ ] improve documentation
