Hi everyone.
I like your library thanks for that but on Android I have a problem for uploading the document picker res.uri to firebase storage.
Document picker return to me this kind of URI and I don't know how to access the path to upload the file to Firebase storage.
content://com.google.android.apps.docs.storage/document/acc%3D1%3Bdoc%3Dencoded%3DyKmSCMqeCKVTPyqzPBQwP9s3jDoaWmxNZFg0XpXjHOqhWlxe8%2F1LMqI6
Firebase won't accept this kind of URI it return to me an unknown error.
If I pick a document from the internal phone It works as excepted.
Everything work as expected on IOS and also for Google Drive content.
How to get a correct uri to send it to firebase ?
I saw some post issue on your github but honestly I am french and don't understand all the stuff.
If someone can help me :)
Thanks
Document providers work with URIs, not file paths so you cannot get the file path.
If you want to upload it should be possible to use fetch(content://...).then(res => res.blob()) to get a Blob instance with the contents of the file. Blobs can be used as post content in XHR/fetch and in FormData to do multipart form uploads.
Thanks for your answer
I already try this fetch but cannot get a blob return from google drive content.
It's strange
I use your document Picker function
`try {
const pickedFile = await DocumentPicker.pick({
type: [
DocumentPicker.types.images,
DocumentPicker.types.pdf,
DocumentPicker.types.plainText
],
//There can me more options as well
// DocumentPicker.types.allFiles
// DocumentPicker.types.images
// DocumentPicker.types.plainText
// DocumentPicker.types.audio
// DocumentPicker.types.pdf
});
//Printing the log realted to the file
console.log('pickedFile : ' + JSON.stringify(pickedFile));
console.log('URI : ' + pickedFile.uri);
console.log('Type : ' + pickedFile.type);
console.log('File Name : ' + pickedFile.name);
console.log('File Size : ' + pickedFile.size);
/FETCH HERE/
fetch(pickedFile.uri)
.then(res => {
blob = res
console.log(res)
})
.catch((error) => {
console.error(error);
});
console.log(blob)
const sourcecv = Platform.OS === 'ios' ? { uri: pickedFile.uri, name: pickedFile.name } : { uri: pickedFile.uri, name: pickedFile.name };
this.setState({
cvSource: sourcecv,
isVisibleEdit: false
});
console.log('File CV : ' + this.state.cvSource.uri);
} catch (err) {
//Handling any exception (If any)
if (DocumentPicker.isCancel(err)) {
//If user canceled the document selection
//alert('Canceled from single doc picker');
} else {
//For Unknown Error
alert('Unknown Error: ' + JSON.stringify(err));
throw err;
}
}`
On my firebase upload I use this.state.cvSource to upload with react redux firebase like this
this.props.firebase.uploadFile(
COLLECTIONS.USERS + '/' + this.state.profile.id,
this.state.cvSource.uri,
'',
options
)
.then(snap => {...})
I don't really know how to achieve what I want.
And it's exclusively on ANDROID with GOOGLE DRIVE CONTENT
I'm having the same issue i cannot upload to firebase exclusive in Android when i select docs from dowload folder and from Google Drive if i pick docs from my internal storage directly all works fine