I have a Laravel model which is called for example, Product
, with MySQL table products
underneath. In my React SPA, user have the ability to set background of the product which can be a color (assigned in my React SPA through css), or an image uploaded by that user. The product can be either private, or public (accessible by anyone)
What's the best way to accomplish this?
Solution 1: Store image BLOB or dataURL in MySQL field. Similar to what is described here
Solution 2: Use Laravel Storage - So on altering the product, I would put the image in the Storage, and only store link to that image in MySQL field. Then in my React app, after fetching product, I would need to request the image again (CSS would do that using link provided from the response)
I'm curious if solution 1 is worse because of performance. But as I'm looking at the solution 2, I realize that putting the file in the Storage would require that file to be public. Which solution would you pick and why?