react-native-send-intent
react-native-send-intent copied to clipboard
fix: openFilePicker bug
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)
})
});
}
optimization form https://github.com/lucasferreira/react-native-send-intent/pull/95