Storage or folder
I want to use storage for 2 goals.
Goal one, allow teachers to upload files to the subject. Teachers enrolled in a subject are allowed to upload. Students that can see a task that is linked to a upload in the subject are allowed to download. Should each subject be its own bucket? Or should i simply have one bucket called subject-uploads. and have a folder for each subject?
Goal two, (context. subjects have chapters which contain tasks, a task can be a assignment to which a student can upload their work) Should each assignment be its own buckets or should i just have one bucket called assignment-work. Where each assignment is its own folder and in there there is a folder for each student their upload.
Making just one private bucket makes more sense than one per subject or assignment for managing it. But who would be the owner of the bucket. And who should be the owner of the file, the user who uploaded it or the owner of the bucket?
1 Reply
Do not create a bucket for each subject, that will not scale.
In your case, two buckets will suffice:
1. a subject bucket: allows (1) teacher to upload, and (2) students to download.
2. an assignment bucket: allows (1) student to upload, (2) student to download, and (3) teacher to download.
Whenever you need different access control, you'll create a new bucket.
E.g.,
subject-uploads → <subject_id> → [file1.pdf, file2.pdf].
You’ll then need to apply RLS to the bucket so that only teachers have permission to upload files, while students are limited to SELECT/download access. Since RLS must be configured per bucket, this approach doesn’t scale well if you create a separate bucket for each subject.