avatars bucket where signed-in people can upload to their own folder.
1. Create the bucket in Studio
- Open your project and choose the
developmentenvironment. - In the sidebar choose Storage (under Services).
- Click New bucket.
- Set Name to
avatars. - Turn on Public bucket (anyone with an object’s URL may read it; uploads, listing and deletes still follow the rules below).
- Under Who may upload new objects, open the rule picker and choose Custom condition. Add one rule: Compare values… with
$object.segments.0equals$auth.user_id. This means a person can upload only under their own id. - Under Uploads, set Accepted types to
image/*and Largest file to2(MB). - Click Create.
2. Upload a file in Studio
In the file browser click Upload, choose an image. It appears in the list with its size and type. Click it to open its panel: the Overview tab shows its Gateway URL, the address your app uses.3. Upload from your app
Sign a person in first (Auth), then:4. Prove the rule
Try to upload to someone else’s folder:What you have now
- A public bucket that only accepts images up to 2 MB.
- A rule that keeps people to their own folder.
- A URL you can put in an
<img>.
Bucket settings
Every setting explained.
Upload
Large files, progress, errors.