question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue to load a image blob for firebase

See original GitHub issue

Hi my name is Kevin, and I am having a issue when I try to convert a uri to a blob.

I actually I am using the version 0.55 of react native and 0.10.12 of the library and this is my code

` uploadImage = (mime = ‘image/jpeg’, name) => { const Blob = RNFetchBlob.polyfill.Blob; const fs = RNFetchBlob.fs; window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest; window.Blob = Blob; var uri = this.props.image;

return new Promise((resolve, reject) => {
  let imgUri = uri; let uploadBlob = null;
  const uploadUri = Platform.OS === 'ios' ? imgUri.replace('file://', '') : imgUri;
  const { currentUser } = auth;
  const imageRef = storage.ref(`/images/${currentUser.uid}`)

  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)
  })
})

}`

When I run this line window.Blob = Blob; I am getting this error

photo5127487053985064978

I read this issue in react-native-fetch-blob, but this does not have any solution

Thanks to read my problem and thanks for your work

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

1reaction
sertonycommented, Feb 11, 2019

@ManalLiaquat I’d be glad to help, but I don’t use expo in my projects.

1reaction
ManalLiaquatcommented, Feb 11, 2019

@sertony Maybe it helps you See this gist

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploaded Image Blob To Firebase - Missing Next Steps
Try using Firebase Storage to store the blob in a correct place while getting a downloadableUrl const uploadFile = async = (blob) =>...
Read more >
Upload files with Cloud Storage on Web - Firebase
To upload a file to Cloud Storage, you first create a reference to the full path of the file, including the file name....
Read more >
Image optimization with Firebase Extensions - Invertase
Image optimization with Firebase Extensions. In this blog, the use-case discussed is about images and Cloud Storage triggers.
Read more >
Uploading Images to Firebase Storage (and retrieving them)
Firebase is a platform that contains many useful features including the Firestore database which we've used in the past.
Read more >
Evan Bacon on Twitter: "Firebase storage upload doesn't work ...
and your file will be 0kb on Firebase. Anyone who knows RN Blob API S.O.S ❤️" / Twitter ... I have no problem...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found