Skip to content

fix: openFilePicker bug#130

Open
1uokun wants to merge 1 commit intolucasferreira:masterfrom
1uokun:master
Open

fix: openFilePicker bug#130
1uokun wants to merge 1 commit intolucasferreira:masterfrom
1uokun:master

Conversation

@1uokun
Copy link
Copy Markdown
Contributor

@1uokun 1uokun commented Sep 1, 2020

Usage

Basic usage

SendIntent.openFilePicker({
    type:"*/*",
    title:"Choose file",
    multiple:false
},(e)=>{
    console.log(JSON.parse(e))
});

Picker the specified type file, eg:".PDF"

SendIntent.openFilePicker({type:"application/pdf"},(e)=>{
   console.log(JSON.parse(e))
});

Multiple File Picker

SendIntent.openFilePicker({multiple:true},(e)=>{
   console.log(JSON.parse(e))
});

Permission

need READ_EXTERNAL_STORAGE

const granted = await PermissionsAndroid.request(
    PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
    {
        title: '"need READ_EXTERNAL_STORAGE permission",
        message:
                  'If not allowed, you will not be able to picker someone file',
        buttonNeutral: 'Later',
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
    },
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
    SendIntent.openFilePicker({},(e)=>{
        // check returns is a real path
        FetchBlob.fs.stat(JSON.parse(e)[0]).then(res=>{
            console.log(res)
        }).catch(err=>{
            console.log(err)
        })
    });
}

@1uokun
Copy link
Copy Markdown
Contributor Author

1uokun commented Sep 1, 2020

optimization form #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant