Hey guys! I just wondered if it's possible to have...
# help
n
Hey guys! I just wondered if it's possible to have a trigger so that when a file is uploaded to the storage, it gets information of that file (the filename, the url, the file type) and store it within a table in the database?
n
Hello @nicedaynot! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
Yes you can put a trigger on object table, but it is a bit tricky... This shows just storage createObject: https://github.com/supabase/storage-api/blob/master/src/routes/object/createObject.ts lines 130-140 is the first insert with name/path of object and bucket, lines 224-230 is update with metadata. Note between this if the file fails being stored to S3 then there is a delete database call. So you have to decide which of the 3 to track, you might be able to use just an update trigger at end. Of course that also might trigger if you update the file later...
n
nicedaynot (2022-04-18)