Hello, I have a quick question, is it possible to ...
# help
c
Hello, I have a quick question, is it possible to set up triggers on insert/update into a storage bucket? I want to update a row in a table in my public schema when that happens
n
Hello @CornusAmmonis! 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
You can have triggers on any table. If you want to deal with file uploads/updates you probably want the storage.object table. Warning... when uploading a file there is an insert to the object table, then the storage api code does the upload to S3, then it updates the object table if successful, otherwise is deletes the row in the object table. If you trigger just on insert your results may be inaccurate. In particular the table row could get deleted, or if you want metadata you have to get that on the update.
n
CornusAmmonis (2022-04-27)
c
ok, so probably best only to trigger on update then, thank you
also, is there any way to set a per-bucket file size limit or otherwise limit size via policy? or does the limit have to apply to all buckets
g
I won't say no... but the only time you can know at the database level is on that update. If you look at the create object code: https://github.com/supabase/storage-api/blob/master/src/routes/object/createObject.ts And if you can cause the update to fail AND that code then deletes the file already loaded probably. Otherwise you need a server process to prescan the file data before calling the storage api... I believe.
c
thank you! that's very helpful
you all have some sharp people doing support. again I appreciate it
g
Just to make sure there is no confusion, this Discord is mainly users helping users unless you see "team" in the user handle. I'm reading their code here based on past interactions and giving you my best guess...
c
oh I see, thanks for the clarification, either way, you've really helped me out