Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: openFilePicker bug #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

1uokun
Copy link
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
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.

None yet

1 participant