Skip to content

docs(storage_management): fix delete_old_avatar#15530

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

docs(storage_management): fix delete_old_avatar#15530
saltcod merged 3 commits intosupabase:masterfrom
grafovdenis:update_storage_management_docs

Conversation

@grafovdenis
Copy link
Contributor

@grafovdenis grafovdenis commented Jul 3, 2023

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
Copy link

vercel bot commented Jul 3, 2023

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

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Sep 1, 2023

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
Copy link

vercel bot commented Sep 1, 2023

Deployment failed with the following error:

There is no GitHub account connected to this Vercel account.

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