If a user changes their name or profile picture I want to update a JSON object that is stored at a publically available Firebase URL that holds these values. Is this possible in Firebase - basically reusing a URL?
It would stop me from having to update a lot of data in the Firestore collection.
Example:
Edit: There are no code problems or bugs as I haven't written it. I cant even find it online
If you are using a structure that is similar to this one:
Firestore-root
|
--- users (collection)
|
--- $uid (document)
|
--- profilePhoto: "https://firebasestorage_images.mobileapp.com/uid-123456"
To read the URL that is associated with the user account, you only need to know the UID. So it doesn't really matter what does the profilePhoto
field contain, the path to reading it will always be the same.
If you are looking to always have a unique URL, that's not possible. When you upload a photo to Firebase Storage, a token is generated. So even if you are using the same name, the new photo overwrites the old one, but a new token is generated. Such an URL looks like this:
https://firebasestorage.googleapis.com/v0/b/your_app.appspot.com/o/photos/leon.jpg?alt=media&token=617c54b9-5d4c-...
You cannot use an old token to update new images.