Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Firebase upload throwing error on beta.6 #95

Closed
shilpan opened this issue Aug 20, 2016 · 4 comments
Closed

Firebase upload throwing error on beta.6 #95

shilpan opened this issue Aug 20, 2016 · 4 comments

Comments

@shilpan
Copy link

shilpan commented Aug 20, 2016

My code is as follows:

RNFetchBlob
  .config({ fileCache : true, appendExt : 'png' })
  .fetch('GET', 'https://avatars0.githubusercontent.com/u/5063785?v=3&s=460')
  .then((resp) => {
    let rnfbURI = RNFetchBlob.wrap(resp.path())
    let filename = uuid.v4() + '.png';

    // create Blob from file path
    Blob
      .build(rnfbURI, { type : 'image/png;'})
      .then(blob => {
        return firebase.storage()
          .ref('rn-firebase-upload')
          .child(filename)
          .put(blob, { contentType : 'image/png' })
          .then((snapshot) => {
            blob.close();
            console.log('<---success--->');
          })
      })
      .catch(err => console.log(err));
  });

As you can see, most of the code is copied from the rn-firbase-storage-upload example. However I get the error:
Firebase Storage: Invalid argument in "put" at index 0: Right-hand side of 'instanceof' is not an object

It seems like firebase is not able to assert the blob's structure accurately.

@wkh237
Copy link
Owner

wkh237 commented Aug 20, 2016

@shilpan , I can't reproduce the error and the code looks fine. I'm wondering what's blob looks like ? could you print its value ?

@shilpan
Copy link
Author

shilpan commented Aug 20, 2016

Here's the JSON:

{"listeners":{},"isRNFetchBlobPolyfill":true,"multipartBoundary":null,"_ref":"/data/user/0/com.stitchapp/files/RNFetchBlobTmp_9773cc40-9d80-4bb0-95c9-12e3d0bff475","_blobCreated":true,"_closed":false,"cacheName":"blob-28424677-cd79-4ece-bc6c-7a4feae19bca","type":"image/png;","size":"35208"}

Let me know if you need more details

@wkh237
Copy link
Owner

wkh237 commented Aug 20, 2016

Okay, the blob instance looks good. After some attemps I still can not reproduce the problem, could you provide a simplified sample app that make this happen ? It'd be very helpful !

@shilpan
Copy link
Author

shilpan commented Aug 20, 2016

Okay this resolves the issue:

window.Blob = RNFetchBlob.polyfill.Blob;

from

window.Blob = RNFetchBlob.Blob;

But I did get a resolution. So I will close this issue. Thanks :)

@shilpan shilpan closed this as completed Aug 20, 2016
julian-becker pushed a commit to julian-becker/react-native-fetch-blob that referenced this issue Mar 30, 2022
* Media store support

fixes wkh237#95
fixes wkh237#62
fixes wkh237#100
fixes wkh237#91
Merge remote-tracking branch 'origin/develop'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants