0

I am trying to save the data in the firebase real-time database using the set() method. I can save the name of food and id successfully. But unable to save the images. Meantime I have to retrieve the saved data into the flat list. Can you pls help me to save the image data in firebase in realtime?

Here is the button with onPress() for passing parameters to the addtofavorites()

<TouchableOpacity
                  onPress={() =>
                    addToFavourites(item.menuId, item.name, item.photo)
                  }>

Here is the database method

 //Database
  const addToFavourites = async (id, foodname, image) => {
    //get current user
    var user = await auth().currentUser.uid;

    //get Unique key
    var databaseRef = await database().ref(user).child('favourites').push();

    //update the details
    databaseRef.set({
      menuId: id,
      name: foodname,
      image: image,
    });
  };
Younes
  • 462
  • 7
  • 15
Nusry KR
  • 105
  • 1
  • 3
  • 13
  • You should take a look at another answer. See here: https://stackoverflow.com/questions/13955813/firebase-storage-how-to-store-and-retrieve-images – Maned Wolf Feb 08 '21 at 05:55
  • Images should likely be stored in Storage and not RTDB. You can store the meta info about the image in the database. There are a number of [example apps and codelabs](https://firebase.google.com/docs/samples/) that can walk you through storing images. – Kato Feb 08 '21 at 16:36

0 Answers0