jar
06/12/2022, 3:52 AMselect publicURL from storage.objects where id = '...'
something like this maybe. But i dont see a url in that so maybe something elseNeedle
06/12/2022, 3:52 AMjar
06/12/2022, 4:03 AMgaryaustin
06/12/2022, 1:03 PMjar
06/12/2022, 1:07 PMjar
06/12/2022, 1:08 PMjar
06/12/2022, 2:01 PMif not myitem.image_storage_object_id is null then
select * from storage.objects where id = myitem.image_storage_object_id into storage_object;
image_src := 'https://myrandomprojstring.supabase.co/storage/v1/object/public/' || storage_object.bucket_id || '/' || storage_object.name;
end if;
garyaustin
06/12/2022, 3:09 PMgaryaustin
06/12/2022, 3:17 PMjar
06/12/2022, 3:19 PMgaryaustin
06/12/2022, 3:20 PMjar
06/12/2022, 3:49 PMcreate or replace function get_public_url_from_storage_object_id(storage_object_id uuid) returns text as $$
declare
storage_object storage.objects%rowtype;
image_src text;
cur_setting jsonb;
instance_id text;
begin
if not storage_object_id is null then
select * from storage.objects where id = storage_object_id into storage_object;
cur_setting := current_setting('request.headers', true)::jsonb;
instance_id := cur_setting->>'x-forwarded-host'::text;
image_src := 'https://' || instance_id || '/storage/v1/object/public/' || storage_object.bucket_id || '/' || storage_object.name;
end if;
return image_src;
end;
$$ language plpgsql