Skip to content

docs(storage_management): fix delete_old_avatar - #15530

Merged
saltcod merged 3 commits into
supabase:masterfrom
grafovdenis:update_storage_management_docs
Sep 1, 2023
Merged

saltcod merged 3 commits into
supabase:masterfrom
grafovdenis:update_storage_management_docs

Conversation

@grafovdenis

@grafovdenis grafovdenis commented Jul 3, 2023 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

It fixes delete_old_avatar usage.

What is the current behavior?

We have avatars bucket, and avatar_url field in public.profiles table and trigger delete_old_avatar, which uses delete_avatar, which uses delete_storage_object.
Once we edit the avatar_url, related storage object should be removed.
But it doesn't happend, because delete_old_avatar takes old.delete_old_avatar, which looks like https://project_id.supabase.co/storage/v1/object/sign/avatars/avatar_id.jpg?token=some_token and puts it into delete_avatar, which calls delete_storage_object and instead of avatar_id.jpg we provide full URL.

In a result, even if we change or remove avatar_url, previous avatars remain in the storage. Because we'll have 404 error in DELETE HTTP request.

What is the new behavior?

Intead of avatar_url, avatar_name is now provided to delete_avatar in delete_old_avatar trigger.
Which makes it work as supposed.
If we edit avatar_url, old avatar would be deleted from the storage.

@grafovdenis
grafovdenis requested a review from a team as a code owner July 3, 2023 12:56
@vercel

vercel Bot commented Jul 3, 2023

Copy link
Copy Markdown

@grafovdenis is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 1, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 1, 2023 6:16pm
studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 1, 2023 6:16pm
studio-self-hosted ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 1, 2023 6:16pm
studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 1, 2023 6:16pm
zone-www-dot-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 1, 2023 6:16pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
ui-storybook ⬜️ Ignored (Inspect) Visit Preview Sep 1, 2023 6:16pm

@vercel

vercel Bot commented Sep 1, 2023

Copy link
Copy Markdown

Deployment failed with the following error:

There is no GitHub account connected to this Vercel account.

This branch was successfully deployed

5 active deployments
Preview – docs — 0c217f14 Deployed Sep 1, 2023 by vercel[bot]
Preview – zone-www-dot-com — 0c217f14 Deployed Sep 1, 2023 by vercel[bot]
Preview – studio-staging — 0c217f14 Deployed Sep 1, 2023 by vercel[bot]
Preview – studio — 0c217f14 Deployed Sep 1, 2023 by vercel[bot]
Preview – studio-self-hosted — 0c217f14 Deployed Sep 1, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants