SQL command instead of js sdk

Is there a sql command to create a signed link? And is there a sql command to create a bucket with params like max file size or restricted MIME types?
7 Replies
garyaustin
garyaustin2w ago
No on signed link. But there is a plain Rest API without JS. You can create a bucket with sql by inserting into storage.buckets.
Idris
IdrisOP2w ago
Ah thats unfortunate I got a RPC that gives a user a list of tasks they got, was thinking of also sending signed urls with it so they can have fast access, but perhaps I should sent the link of the bucket file itself and use their token in the header to access it instead. Unfortunatly that means I need some complex RLS policy to check if the user has a task they can see that has the file linked. Any suggestions? Some context: some students can see some tasks, a task can have a file linked to it via a text[] column in the task row. Only files that are linked to tasks a student can see should be able to be downloaded.
garyaustin
garyaustin2w ago
You could call the Rest API with the http extension.
Idris
IdrisOP2w ago
Yeah, the downside would be that it would significatly make the RPC slower. and like 10% of the time they would use the signed url. I think I will make a edge function, get download link, this would take the task id and the url it wants to download. This would be super fast since it has the task id so it can instantly check if they have access to the task id, and if the url is linked to the task. and if so provid a signed url. Would this be a good idea, or do you think i can make the RLS route work with denormilization or maybe get all download access security defined function that is used to compare the download link?
garyaustin
garyaustin2w ago
Not reading too closely right now but edge function seems like a good idea.
Idris
IdrisOP2w ago
Do you know if there is a sql command to create a bucket with the params like you can with the js sdk
silentworks
silentworks2w ago
What exactly are you trying to set? You can create a bucket using the following SQL
insert into storage.buckets (id, name, public)
values ('user_images', 'user_images', true);
insert into storage.buckets (id, name, public)
values ('user_images', 'user_images', true);
These are just come of the columns, if you look in the buckets table you will find the other columns that you can set too e.g. file_size_limit, allowed_mime_types

Did you find this page helpful?