Allow database row to associate to a specific storage file

Is it possible to associate a database row to a specific storage file. Example: Database - Products Storage - Product_Files Database Row1 - needs to have the 1st image uploaded Databasse Row2 - needs to have the 2nd image uploaded
... etc
1 Reply
garyaustin
garyaustin4y ago
The easiest way is to just save the image bucket/path in your products row. You will need that anyway to use a storage call to get it (or can use it directly in a url if a public bucket).
You could also have a foreign key to the storage object table id, but I don't know if that is even returned when you upload the file (so an extra call to get it). And even with that you would have to do a select call to the object table to get the path to actually download the file or get it's url. You really should not add a foreign key to the objects table as you don't control that schema.

Did you find this page helpful?