fix(exam): source-PDF upload uses shared cc.users bucket (S4-8.1 merge-gate fix)
Pre-merge live smoke on .94 caught 'Bucket not found': the upload wrote to a per-institute bucket cc.institutes.<id>.private that isn't provisioned on dev. Use the shared SOURCE_BUCKET_FALLBACK (cc.users); institute is namespaced in the storage path + enforced by the files-row RLS. Per-institute buckets are a future multi-tenant concern. Catalogue path + cross-institute 404 already verified green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
c58df6715c
commit
c0775f3be1
@ -167,8 +167,12 @@ async def _upload_template_source_file(
|
|||||||
|
|
||||||
file_id = str(uuid.uuid4())
|
file_id = str(uuid.uuid4())
|
||||||
safe_name = os.path.basename(upload.filename or "template.pdf")
|
safe_name = os.path.basename(upload.filename or "template.pdf")
|
||||||
bucket = f"cc.institutes.{institute_id}.private" if institute_id else SOURCE_BUCKET_FALLBACK
|
# Use the shared users bucket (exists on all envs). Per-institute private buckets
|
||||||
storage_path = f"exam-marker/{cabinet_id}/{file_id}/{safe_name}"
|
# (cc.institutes.<id>.private) are a future multi-tenant provisioning concern and are NOT
|
||||||
|
# created on dev .94 — using one here failed with "Bucket not found". The institute is already
|
||||||
|
# namespaced in the storage path + enforced by RLS on the files row.
|
||||||
|
bucket = SOURCE_BUCKET_FALLBACK
|
||||||
|
storage_path = f"exam-marker/{institute_id or 'noinst'}/{cabinet_id}/{file_id}/{safe_name}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
storage.upload_file(bucket, storage_path, file_bytes, "application/pdf", upsert=True)
|
storage.upload_file(bucket, storage_path, file_bytes, "application/pdf", upsert=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user