I have an app onto Firebase when users can register themselves and have to be also able to upload an image/avatar onto the backend.
In the first place I wanted to stick to something like Amazon S3, but then I thought it would have been better keeping simple.
So.. for not-large scaled apps, can it be considered a good practice storing images in a sub JSON Tree?
By good practice I mean:
- It won't hurt drammatically query performances
- It would be recommended by experts programmers with experience in NoSQL dbs
- It won't hurt other json trees query performances
I wonder about this because I know that storing files is discouraged in dbs, and NoSQL dbs can furtherly suffer in performances.
I was thinking to store images in a sub json tree like /avatars, where the key/value pair should be:
-user1_uid: image_base64...
-user2_uid: image_2...
-....
Where the image value is a Base64 string of the image, so can converted back to a file.
The images would be so fetched:
I get the uid key of the user I want to fetch the image of.
I query the image value from myapp.io/avatars/userX_uid (server side filtering)
I use the image.
So... can it be defined a good practice?
Thanks in advice
EDIT: I'm now thinking also about image caching... How should I cache these images after fetching them? Since it's not about simple urls anymore I should have to do this manually..