Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React Native, Uploading to firebase.storage() without expo, without react-native-firebase, NSMutableURLRequest, Missing Request Token

$
0
0

I am trying to upload to firebase.storage(). The code was working when I built the app in expo but not when I rebuilt with react-native-cli . I get a terminal error and an ios simulator error.

If possible I am hoping to do this without react-native-firebase: https://github.com/invertase/react-native-firebase

I can not find much documentation on doing this without importing react-native-firebase. Is importing this package the industry best practice? I wouldn't think so... I am currently under the impression, as a new developer, that extra packages tend to make a project bloated with superfluous code. However, this one could be be necessary?

FYI, other firebase requests still work, ie data called to populate my flatlists and firebase.auth() works as-well.

Any help is greatly appreciated, Ive been stuck for days. Thank you..

TypeError: Network request failedhttp://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29655:33_callTimer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30546:17callTimers@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30754:19__callFunction@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2802:36http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2534:31__guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2756:15callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2533:21callFunctionReturnFlushedQueue@[native code]

Uploading code:

    addPost = async ({  uid, username, postDescription, postPhoto}, dispatch) => {        const remoteUri = await this.uploadPhotoAsync(postPhoto, `photos/#{this.uid}/${Date.now()}`)        const timestamp = this.timestamp        const postContent = await {             uid,            timestamp: timestamp,            username,            postDescription,            postPhoto: remoteUri,          }        this.db.collection("posts").add(postContent)        .catch(error => {            rej(console.log("Add post error" + error));        })    }    uploadPhotoAsync = async uri => {        const path = `photos/${this.uid}/${Date.now()}.jpg`        return new Promise(async (res, rej) => {            const location = await uri            const response = await fetch(location)                        const file = await response.blob()            let upload = firebase                .storage()                .ref(path)                .put(file);            upload.on("state_changed",                 snapshot => {},                 err => {                rej(err)                },                async () => {                    const url = await upload.snapshot.ref.getDownloadURL();                    res(url);                }            )         })    };

enter image description here


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>