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

java.lang.String com.facebook.react.bridge.ReadableMap.string(java.lang.string) on a null object Reference while uploading image to firebase #119

Closed
mohammdwaqas opened this issue Jul 17, 2018 · 4 comments · Fixed by #121

Comments

@mohammdwaqas
Copy link

mohammdwaqas commented Jul 17, 2018

i am getting above error while trying this code to upload image to firebase

`function uploadImage() {

        return new Promise((resolve, reject) => {
            let imgUri = 'content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F80/ORIGINAL/NONE/1685675380'; let uploadBlob = null;
            const uploadUri = Platform.OS === 'ios' ? imgUri.replace('file://', '') : imgUri;

            const imageRef = firebase.storage().ref();
            const name = 'myimg';
            mime = 'image/jpeg';
            fs.readFile(uploadUri, 'base64')
                .then(data => {
                    return Blob.build(data, { type: `${mime};BASE64` });
                })
                .then(blob => {
                    uploadBlob = blob;
                    return imageRef.put(blob, { contentType: mime, name: name });
                })
                .then(() => {
                    uploadBlob.close()
                    return imageRef.getDownloadURL();
                })
                .then(url => {
                    resolve(url);
                })
                .catch(error => {
                    reject(error)
                })
        })
    }`

dependencies:

"react-native": "^0.55.3", "react-native-firebase": "^4.1.0", "react-native-image-picker": "^0.26.10", "react-navigation": "^2.6.0", "rn-fetch-blob": "^0.10.11"

any help ?
snap

@mohammdwaqas mohammdwaqas changed the title java.lang.String com.facebook.react.brifgr.ReadableMap.string(java.lang.string) on a null object Reference while uploading image to firebase java.lang.String com.facebook.react.bridge.ReadableMap.string(java.lang.string) on a null object Reference while uploading image to firebase Jul 17, 2018
@ihavenoface5
Copy link
Collaborator

I found one place (addCompleteDownload) where getString was called on a ReadableMap without a check if the path key exists. I will submit a pull request.

@bsjaffer
Copy link

I am getting same issue when i add below code snippet .
//
window.Blob = Blob;

@diesmori
Copy link

diesmori commented Feb 4, 2019

I just solved it following rainbarrel's solution at wkh237#634, doing the same for window.Blob, because I got the "unsupported bodyinit type" error right after the mentioned solution.

@tram421
Copy link

tram421 commented Apr 13, 2019

You can try this:
replace:
const uploadUri = Platform.OS === 'ios' ? imgUri.replace('file://', '') : imgUri;
To:
const uploadUri = imgUri;
This work for me (on android).

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 a pull request may close this issue.

5 participants