-1

In Cloud Firestore, I want to add a collection like for ex. A,B,C and ..... within document I want to add two things(fields) basically

  1. a image, and
  2. a URL

Since I am new to Firebase ...Can anyone help me with this problem

Gourav B
  • 864
  • 5
  • 17
  • 2
    There is no field as url. Simply mark the field as string..and save the url as string. In case you want to save images as well ...first you can upload the image to firebase storage and get the downloadurl from that..and then save it in the firestore doc – Vinamra Jaiswal Jan 13 '22 at 10:37
  • Hi, what did you try? – Renaud Tarnec Jan 13 '22 at 12:47
  • Hi @RenaudTarnec sir , Actually I am a beginner so , I just so confused so I didn't try anything yet. Can you give any idea how i can proceed forward... – ANVAY ABHIRAAJ Jan 13 '22 at 13:51
  • 2
    A Collection (= Documents container) is automatically creates when you create the first document in this collection. I'd suggest that you read the doc: https://firebase.flutter.dev/docs/firestore/usage and https://firebase.google.com/docs/firestore – Renaud Tarnec Jan 13 '22 at 13:54
  • @RenaudTarnec..thank you sir ... – ANVAY ABHIRAAJ Jan 13 '22 at 13:57
  • Please see "[ask]" and the linked pages and "[MCVE]". We appreciate that you might be new, but we do expect evidence of the effort you've put into this. Where did you search? Why didn't it help? If it did, where is the code you wrote to test what you learned? If you didn't write code, why not? If you did, what is the minimal code that demonstrates the problem you encountered, along with the explanation of the problem, and the minimal input data and the expected result? Without that it's hard to help you. – the Tin Man Feb 04 '22 at 21:59

1 Answers1

1

As suggested by Vinamra Jaiswal, you need to store the URL as a string in the Firestore, you can refer to "How to store multiple url in firestore using flutter" for an example.

As for the image you can refer to "firestore database add image to record", where you can see that it is wiser to store the images in the Cloud Storage and then download the URLs and store them in Firestore.

You can also refer to the "Upload image to Cloud Storage, save URI in Firestore" video to get more insight on how to do this.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Zeenath S N
  • 1,100
  • 2
  • 8