uploading BASE64 images to firebase storage

358 views
Skip to first unread message

thanvi...@gmail.com

unread,
Jun 27, 2018, 10:07:52 AM6/27/18
to Firebase Google Group
hi,
i am building react-native app.
i am using react-native-image-picker for uploading images from library and camera roll etc

as a a response i get BASE64 data such as 

/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAAB...........etc

my code is below-------

return (dispatch) => {
    dispatch({ type: HOME_PHOTO_URL_REQUEST });
    firebase.storage()
    .ref('new')
    .child(imageRef + new Date())
    // .put(blob, { contentType: 'image/jpg' })
    .putString(imagedata, 'base64', {contentType:'image/jpg'})
    .then((snapshot) => {
      const url = snapshot.metadata.downloadURLs[0];
      // const url = snapshot.metadata.downloadURLs;
      console.log('urls:', snapshot);
      dispatch({ type: HOME_PHOTO_URL_SUCCESS, payload: url });
    })
    .catch((error) => {
      dispatch({ type: HOME_PHOTO_URL_FAIL });
    });
  };

the upload is successfull and i get a url back from firebase storage but it does not show any images


any insight into it will be helpful
thanks
Reply all
Reply to author
Forward
0 new messages