Hello!
So I've been racking my brain trying to come up with the best solution for a problem I need to tackle in the next few days. I would really appreciate some good ideas or some tips on best practices from anybody who reads this.
So I have a Laravel API (laravel 5), which is the backend to an angular front end. One of the fields in the database for the User is the avatar. Currently they can use an image URL to show an avatar image (which they can pull in through facebook and google).
I'm creating the functionality to upload an image to the backend so they can set a custom avatar using whatever image they want. Now I'm contemplating how I should store the images and how I should return them.
the rest of the API communicates solely with json responses etc... anyway here are my ideas
#1 so I'm wondering if I should just grab the image and store it in the database as a base64 string or something, and then return it when it is requested. I could then decode it and display it on the front end.. but is that a good idea? Not sure how it would perform.
#2 Would it be better for me to just put the images in the file storage somewhere using the Storage facade, and then actually serve them up from my php backend... then in the API response I could send a URL to the image location? The benefit of this to me would be I could eventually store them on amazon cloud or something.
#3 Another option is I could store them in my public folder and then serve them up and do the same as I said above except for without using Storage.
#4 Should I upload to some other image hosting service, and then just return the URL to the front-end?
#5 is there an idea that is better then all my other ideas? maybe I store in Storage... and then return them as base64 strings rather then serve it up?
#6 I could use a service like cloudinary, and host files there.. then just return the cloudinary url to my frontend..
Also i'm not looking for the easiest solution.. I'm looking for the best long term solution, because we are building this for a large user base.
Thanks!