MFS401 : Table of Contents

Chapter 4

Lesson 2

Storage Reinforced: Access Control, Caching and Image Transformation


Supabase Storage dashboard

Overview of Caching and CDN


Optimized images through Supabase image transformations

Deep dive into Smart CDN cache invalidation

Quiz it to win it

Take the quiz

6 Questions
12 XP

We saw in the previous lesson that making buckets private is one of the easier ways to restrict access to assets within the bucket. But this black-and-white access control may not be enough in all use cases. Blissfully, since Supabase Storage uses Postgres internally for storage metadata, we have access to mighty RLS, and thus we can write complex access policies on storage access.

But before we start writing RLS policies, we need to understand how the metadata is stored in the Postgres DB.

If we go to the storage schema in our DB, we can see three tables. These tables are read only as it is managed by supabase, and changing anything in these tables may cause things to break. The two tables relevant to this lesson are:

  • the buckets table: This table contains information about each bucket. We can see entries for the buckets we created in the previous lesson. This contains details such as whether the bucket is public or not, file size limit, allowed media type, and other metadata.
  • the objects table: This table contains info for each object or asset in the storage. Here, we can see the images we added to our storage. This contains info like the name, parent bucket, path and other metadata of the asset.
  • To manage access on bucket level operations (such as creating a new bucket, or updating/deleting an existing bucket), we need to add RLS policies on the buckets table.

    Get started for free today!

    No commitments. No contracts. Enjoy all features for a day — join in just three clicks!

    No credit card required.

    Quiz it to win it

    Complete this quiz successfully to proceed to the next lesson and win upto 12XP.

    Start quiz for this lesson

    Completing this quiz will get you

    +12 Experience Points

    +5% course progress