i am trying to upload doc files from expo cli to my firebase storage in react native but it gives me network error.
i use document picker to get file uri from storage and then i use this function to upload it to my firebase storage.
const uploadDocuments = () => {
let recievedDocs = [];
document.map(async (item, index) => {
var docName = user.uid + Math.floor(Math.random() * 127212);
const response = await fetch(item.uri);
const blob = await response.blob();
var ref = firebase.storage().ref("postDocs/documents/" + docName);
ref
.put(blob)
.then((res) => {
ref
.getDownloadURL()
.then((url) => {
recievedDocs.push(url);
})
.catch((e) => {
alert(e.message);
});
})
.catch((e) => {
alert(e.message);
});
});
};
i also use this function to upload images to firebase storage from image picker and its work fine there but when i use this same function for docs file uri that i get from document picker to upload its give me network error
here is error that i get.
[Unhandled promise rejection: TypeError: Network request failed] at node_modules\whatwg-fetch\dist\fetch.umd.js:535:17 in setTimeout$argument_0 at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:383:16 in callTimers at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue