Jesus Dimrix
Jesus Dimrix

Reputation: 4578

Uploading object to fireBase with image attached on android

Is there a way to upload object , Lets say for the example it is a User , with image to fireBase ?

According to what i have read i need to upload the user's image to storage and than upload the User to the Real time Db with the url i received when i uploaded the image in the first step .

is there a way on fire base to upload the user with the image on one Request so i will not have to

1 . do 2 request

2 . connect the request with an id so the user will know the image

3 . handle 2 requests responses .

Thanks .

Upvotes: 1

Views: 97

Answers (2)

Alex Mamo
Alex Mamo

Reputation: 138824

No, there is not! You should do two separate operations, one for storing the image into Firebase Storage and getting the url at the same time and second to upload that url to Firebase database. This means that 2 requests are needed.

//This how you initialize Firebase Storage
FirebaseStorage storage = FirebaseStorage.getInstance();

//This how you initialize Firebase database
DatabaseReference database = FirebaseDatabase.getInstance().getReference();

This two operations needs to be done in order to achieve what you want. Cannot be done in a single request.

Upvotes: 1

user8866321
user8866321

Reputation:

You want to add "object" of user or the String containing the users info?

Upvotes: 0

Related Questions