Repository navigation
What is the best way to handle product images for an ecommerce site in topcoat? #554
|
Currently, I have a rather unscalable method of handling product images. A database table with product data and a unique slug as Id. I have a static hashtable of picture "assets" that is keyed thro' the product slug. Quick and easy for development, but adding new product requires recompiling and redeploy of the application. I don't see a way of dynamically generating "assets", so dynamic uploading of product images will not be possible. I'm thinking it might be best to store a URL in the product table that links to the product image provided by a CDN. |
Replies: 1 comment 2 replies
|
storing an image URL with the product is a good fit here keep uploaded files in object storage and serve them through its public image URL or your CDN then use that URL as the img src the compiled asset pipeline can stay for application images such as logos product uploads do not need to become compiled assets store a generated object key as well if you need to replace or delete an upload later avoid using the original upload filename as a unique key |
yes a separate nginx container serving the product images is a reasonable setup
you still need persistent storage for uploads if topcoat receives them mount the same media volume read write in topcoat and read only in nginx nginx serves those files through a stable image URL and your product record stores that URL
so it separates serving from the application rather than removing the volume requirement nginx static files guide
you can put Cloudflare in front of that origin later use new filenames when replacing images or purge the cached URL so customers do not keep seeing the old picture