Your audio-files bucket is private, but you want the samples folder to be publicly accessible.
-
Go to Supabase Dashboard
- Navigate to your project
- Click "Storage" in the left sidebar
-
Access Storage Policies
- Click on "audio-files" bucket
- Click on the "Policies" tab (next to "Files")
-
Create New Policy
- Click "New Policy"
- Choose "For full customization"
-
Configure the Policy
- Policy name:
Public access to samples - Allowed operation:
SELECT(for reading files) - Target roles:
public(for anonymous users) - USING expression:
bucket_id = 'audio-files' AND (storage.foldername(name))[1] = 'samples'
- WITH CHECK expression: Leave empty
- Policy name:
-
Save the Policy
- Click "Review" then "Save policy"
-
Go to SQL Editor
- In Supabase dashboard, click "SQL Editor"
-
Run this SQL command:
CREATE POLICY "Public access to samples" ON storage.objects FOR SELECT USING ( bucket_id = 'audio-files' AND (storage.foldername(name))[1] = 'samples' );
-
Click "Run"
If the above doesn't work, try this more permissive policy:
CREATE POLICY "Public samples access" ON storage.objects
FOR SELECT USING (
bucket_id = 'audio-files' AND
name LIKE 'samples/%'
);- Upload your sample file to the
samplesfolder - Test the URL in a new browser tab:
https://likdbicjuoqqwwrfjial.supabase.co/storage/v1/object/public/audio-files/samples/rick-astley-sample.mp3 - The file should be accessible without authentication
- Allows public read access to any file in the
samplesfolder - Keeps other folders private (user uploads remain secure)
- Only affects the
samplessubfolder withinaudio-files
This is safe because:
- ✅ Only the
samplesfolder is public - ✅ User uploads in other folders remain private
- ✅ Only read access is granted (no upload/delete permissions)
- ✅ Perfect for demo/sample files
If it still doesn't work:
- Check the exact folder name - make sure it's exactly
samples - Verify the file path - should be
samples/rick-astley-sample.mp3 - Try the alternative policy (Method 3)
- Check bucket permissions - make sure the bucket itself allows policies
The policy should work immediately after creation!