Bird
Raised Fist0
Supabasecloud~20 mins

Creating storage buckets in Supabase - Practice Exercises

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Supabase Storage Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What happens when you create a public storage bucket in Supabase?

In Supabase, you create a storage bucket and set its privacy to public. What is the main effect of this setting?

AThe bucket automatically deletes files after 24 hours.
BAnyone can read files in the bucket without authentication.
CFiles in the bucket are encrypted and inaccessible to everyone.
DOnly authenticated users can upload files to the bucket.
Attempts:
2 left
💡 Hint

Think about what 'public' means for file access.

❓ Configuration
intermediate
2:00remaining
Which Supabase CLI command creates a new storage bucket named 'images'?

You want to create a storage bucket called 'images' using the Supabase CLI. Which command is correct?

Asupabase storage create-bucket images
Bsupabase storage create images
Csupabase storage bucket create images
Dsupabase storage buckets create images
Attempts:
2 left
💡 Hint

Check the official Supabase CLI syntax for bucket creation.

❓ Architecture
advanced
3:00remaining
How should you organize buckets for a multi-tenant app in Supabase?

You build an app serving multiple customers (tenants). What is the best way to organize storage buckets to keep data separated and secure?

ACreate one bucket and prefix files with tenant IDs to separate data.
BStore all tenant files in a public bucket for easy access.
CCreate a separate bucket for each tenant to isolate data completely.
DUse a single bucket with no prefixes and rely on client filtering.
Attempts:
2 left
💡 Hint

Think about security and data isolation between tenants.

❓ security
advanced
3:00remaining
What is the effect of enabling 'public' on a Supabase storage bucket with sensitive files?

You accidentally set a bucket containing sensitive files to public. What happens?

AAnyone on the internet can download the files without logging in.
BOnly users with the bucket URL can upload files, but cannot read them.
CFiles remain private because public only affects uploads.
DThe bucket automatically encrypts files to prevent access.
Attempts:
2 left
💡 Hint

Consider what 'public' means for file access permissions.

❓ service_behavior
expert
3:00remaining
What happens if you try to upload a file larger than the Supabase storage limit to a bucket?

You upload a file exceeding the maximum allowed size to a Supabase storage bucket. What is the expected behavior?

AThe upload fails with an error indicating the file is too large.
BThe bucket automatically splits the file into smaller parts.
CThe file uploads successfully but is truncated to the max size.
DThe upload succeeds but the file is inaccessible until resized.
Attempts:
2 left
💡 Hint

Think about how storage services handle size limits.

Practice

(1/5)
1. What is the main purpose of creating a storage bucket in Supabase?
easy
A. To send emails automatically
B. To run server-side code
C. To create a database table
D. To organize and protect files in the cloud

Solution

  1. Step 1: Understand storage bucket purpose

    A storage bucket is used to hold and organize files securely in the cloud.
  2. Step 2: Compare options

    Options B, C, and D describe other services not related to file storage.
  3. Final Answer:

    To organize and protect files in the cloud -> Option D
  4. Quick Check:

    Storage bucket = organize and protect files [OK]
Hint: Buckets store files safely in the cloud [OK]
Common Mistakes:
  • Confusing buckets with databases
  • Thinking buckets run code
  • Assuming buckets send emails
2. Which is the correct way to create a private storage bucket named photos in Supabase?
easy
A. supabase.storage.createBucket('photos', { access: 'private' })
B. supabase.storage.createBucket('photos', { public: false })
C. supabase.storage.createBucket('photos', { private: true })
D. supabase.storage.createBucket('photos', { isPublic: true })

Solution

  1. Step 1: Recall correct method signature

    The method createBucket takes the bucket name and an options object with a public boolean.
  2. Step 2: Identify correct privacy option

    Setting public: false makes the bucket private. Other options use incorrect keys.
  3. Final Answer:

    supabase.storage.createBucket('photos', { public: false }) -> Option B
  4. Quick Check:

    Use public: false for private bucket [OK]
Hint: Use public: false to make bucket private [OK]
Common Mistakes:
  • Using wrong option keys like isPublic or private
  • Setting public: true for private buckets
  • Confusing access property with public
3. What will be the result of this code snippet?
const { data, error } = await supabase.storage.createBucket('docs', { public: true });
console.log(data);
medium
A. An error because 'public' is not a valid option
B. Undefined because createBucket returns nothing
C. An object with bucket details including name 'docs' and public true
D. A boolean true indicating success

Solution

  1. Step 1: Understand createBucket return value

    The method returns an object with bucket info if successful, including name and public status.
  2. Step 2: Analyze the code output

    Since public: true is valid, data will contain bucket details, not an error or boolean.
  3. Final Answer:

    An object with bucket details including name 'docs' and public true -> Option C
  4. Quick Check:

    createBucket returns bucket info object [OK]
Hint: createBucket returns bucket info object on success [OK]
Common Mistakes:
  • Thinking it returns only true/false
  • Assuming it throws error for public option
  • Expecting no return value
4. You wrote this code but get an error:
await supabase.storage.createBucket('files', { public: 'no' });

What is the likely cause?
medium
A. The 'public' option must be a boolean, not a string
B. Bucket name 'files' is invalid
C. createBucket requires a callback function
D. Missing await keyword before createBucket

Solution

  1. Step 1: Check option types

    The public option expects a boolean true or false, not a string.
  2. Step 2: Identify error cause

    Passing 'no' as a string causes a type error. Bucket name and await usage are correct.
  3. Final Answer:

    The 'public' option must be a boolean, not a string -> Option A
  4. Quick Check:

    public option = boolean, not string [OK]
Hint: Use true/false for public, not strings [OK]
Common Mistakes:
  • Passing 'yes' or 'no' as strings
  • Ignoring await keyword
  • Using invalid bucket names
5. You want to create two buckets: one public named images and one private named backups. Which code correctly does this?
hard
A. await supabase.storage.createBucket('images', { public: true }); await supabase.storage.createBucket('backups', { public: false });
B. await supabase.storage.createBucket('images', { public: false }); await supabase.storage.createBucket('backups', { public: true });
C. await supabase.storage.createBucket('images'); await supabase.storage.createBucket('backups');
D. await supabase.storage.createBucket('images', { access: 'public' }); await supabase.storage.createBucket('backups', { access: 'private' });

Solution

  1. Step 1: Set correct privacy flags

    Public bucket needs public: true, private bucket needs public: false.
  2. Step 2: Verify method calls

    await supabase.storage.createBucket('images', { public: true }); await supabase.storage.createBucket('backups', { public: false }); correctly sets these flags. await supabase.storage.createBucket('images', { public: false }); await supabase.storage.createBucket('backups', { public: true }); reverses them. await supabase.storage.createBucket('images'); await supabase.storage.createBucket('backups'); omits privacy, defaulting to private. await supabase.storage.createBucket('images', { access: 'public' }); await supabase.storage.createBucket('backups', { access: 'private' }); uses invalid keys.
  3. Final Answer:

    await supabase.storage.createBucket('images', { public: true }); await supabase.storage.createBucket('backups', { public: false }); -> Option A
  4. Quick Check:

    Public = true, Private = false [OK]
Hint: Public bucket: public true; Private bucket: public false [OK]
Common Mistakes:
  • Mixing up public true/false
  • Omitting privacy option
  • Using wrong option keys like access
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard