Dembe
06/11/2022, 7:44 PMconst { data, error } = await supabaseAdmin.storage
.from("gallery")
.list("categories/sport", {
limit: 100,
offset: 0,
});
Wiht this i just get back the folder, but not the images or subfolder.
Is this possible?Needle
06/11/2022, 7:44 PMgaryaustin
06/11/2022, 8:44 PMcreate function files_in_folder(bucket text, folders text[]) returns text[]
language plpgsql
as
$$
declare filepaths text[];
begin
filepaths := ARRAY(
SELECT name
FROM storage.objects
WHERE bucket_id = bucket AND path_tokens @> folders
);
return filepaths;
end;
$$;
Called like: supabase.rpc('files_in_folder',['folderroot','foldersub1'])
The array is one or more folder names and it will return all files with all folder names in the path including sub folders. The @> is array contains array operation.
Of course this depends on SB storage structure details which is a minor risk for changing in the future.Dembe
06/12/2022, 7:04 PMgaryaustin
06/12/2022, 7:07 PMDembe
06/12/2022, 7:16 PMgaryaustin
06/12/2022, 7:30 PMDembe
06/12/2022, 7:33 PMDembe
06/12/2022, 7:35 PMgaryaustin
06/12/2022, 7:56 PMDembe
06/12/2022, 8:01 PMgaryaustin
06/12/2022, 8:10 PMDembe
06/12/2022, 8:31 PMgaryaustin
06/12/2022, 8:38 PM