docs: Remove storage management section from the quick starts. (#21985)

remove storage management to keep the guide simple
This commit is contained in:
Tyler authored and GitHub committed 2024-03-16 08:03:06 +09:00
1 parent a5ba3f96c5
commit 6b3420a5fd
18 files changed
-177

No files matched your search

@@ -1,111 +0,0 @@
If you upload additional profile photos, they'll accumulate
in the `avatars` bucket because of their random names with only the latest being referenced
from `public.profiles` and the older versions getting orphaned.
To automatically remove obsolete storage objects, extend the database
triggers. Note that it is not sufficient to delete the objects from the
`storage.objects` table because that would orphan and leak the actual storage objects in
the S3 backend. Instead, invoke the storage API within Postgres via the `http` extension.
Enable the [http extension for the `extensions` schema](https://supabase.com/dashboard/project/_/database/extensions) in the Dashboard.
Then, define the following SQL functions in the SQL Editor to delete
storage objects via the API:
```sql
create or replace function delete_storage_object(bucket text, object text, out status int, out content text)
returns record
language 'plpgsql'
security definer
as $$
declare
project_url text := '<YOURPROJECTURL>';
service_role_key text := '<YOURSERVICEROLEKEY>'; -- full access needed
url text := project_url||'/storage/v1/object/'||bucket||'/'||object;
begin
select
into status, content
result.status::int, result.content::text
FROM extensions.http((
'DELETE',
url,
ARRAY[extensions.http_header('authorization','Bearer '||service_role_key)],
NULL,
NULL)::extensions.http_request) as result;
end;
$$;
create or replace function delete_avatar(avatar_url text, out status int, out content text)
returns record
language 'plpgsql'
security definer
as $$
begin
select
into status, content
result.status, result.content
from public.delete_storage_object('avatars', avatar_url) as result;
end;
$$;
```
Next, add a trigger that removes any obsolete avatar whenever the
profile is updated or deleted:
```sql
create or replace function delete_old_avatar()
returns trigger
language 'plpgsql'
security definer
as $$
declare
status int;
content text;
avatar_name text;
begin
if coalesce(old.avatar_url, '') <> ''
and (tg_op = 'DELETE' or (old.avatar_url <> coalesce(new.avatar_url, ''))) then
-- extract avatar name
avatar_name := old.avatar_url;
select
into status, content
result.status, result.content
from public.delete_avatar(avatar_name) as result;
if status <> 200 then
raise warning 'Could not delete avatar: % %', status, content;
end if;
end if;
if tg_op = 'DELETE' then
return old;
end if;
return new;
end;
$$;
create trigger before_profile_changes
before update of avatar_url or delete on public.profiles
for each row execute function public.delete_old_avatar();
```
Finally, delete the `public.profile` row before a user is deleted.
If this step is omitted, you won't be able to delete users without
first manually deleting their avatar image.
```sql
create or replace function delete_old_profile()
returns trigger
language 'plpgsql'
security definer
as $$
begin
delete from public.profiles where id = old.id;
return old;
end;
$$;
create trigger before_delete_user
before delete on auth.users
for each row execute function public.delete_old_profile();
```
-2
View File
@@ -41,7 +41,6 @@ import ProjectSetup from './MDX/project_setup.mdx'
import QuickstartIntro from './MDX/quickstart_intro.mdx'
import SocialProviderSettingsSupabase from './MDX/social_provider_settings_supabase.mdx'
import SocialProviderSetup from './MDX/social_provider_setup.mdx'
import StorageManagement from './MDX/storage_management.mdx'
// Icons
import {
@@ -153,7 +152,6 @@ const components = {
SocialProviderSettingsSupabase,
SocialProviderSetup,
StepHikeCompact,
StorageManagement,
TabPanel: (props: any) => <Tabs.Panel {...props}>{props.children}</Tabs.Panel>,
Tabs: (props: any) => <Tabs wrappable {...props} />,
}
@@ -525,8 +525,4 @@ export class AccountComponent implements OnInit {
}
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -631,8 +631,4 @@ Now you will need to run the prebuild command to get the application working on
expo prebuild
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -856,10 +856,6 @@ class _AccountPageState extends State<AccountPage> {
}
```
### Storage management
<StorageManagement />
Congratulations, you've built a fully functional user management app using Flutter and Supabase!
## See also
@@ -552,10 +552,6 @@ template: `
`
```
### Storage management
<StorageManagement />
At this stage, you have a fully functional application!
## See also
@@ -493,8 +493,4 @@ return (
<Avatar url={profile.avatar_url} onUpload={updateProfile}></Avatar>
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -553,8 +553,4 @@ export default defineComponent({
</script>
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -1467,10 +1467,6 @@ return (
</Tabs>
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
## See also
@@ -434,8 +434,4 @@ async function signOut() {
</template>
```
### Storage management
<StorageManagement />
That is it! You should now be able to upload a profile photo to Supabase Storage and you have a fully functional application.
@@ -396,8 +396,4 @@ return (
)
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -603,10 +603,6 @@ return (
)
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
## See also
@@ -626,8 +626,4 @@ return (
)
```
### Storage management
<StorageManagement />
At this stage, you have a fully functional application!
@@ -415,8 +415,4 @@ return (
)
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -367,8 +367,4 @@ And then we can add the widget to the Account page:
</form>
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -610,8 +610,4 @@ And then we can add the widget to the Account page:
</div>
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -514,8 +514,4 @@ struct Profile: Codable {
You no longer need the `UpdateProfileParams` struct, as you can now reuse the `Profile` struct for both request and response calls.
### Storage management
<StorageManagement />
At this stage you have a fully functional application!
@@ -377,8 +377,4 @@ import Avatar from './Avatar.vue'
</template>
```
### Storage management
<StorageManagement />
At this stage you have a fully functional application!