flip_api.file_services.presigned_url_for_upload
Attributes
Functions
|
Generate a pre-signed POST policy for uploading model files to S3. |
Module Contents
- flip_api.file_services.presigned_url_for_upload.router
- flip_api.file_services.presigned_url_for_upload.get_presigned_url_for_upload(model_id: uuid.UUID, body: flip_api.domain.schemas.file.UploadFileBody, db: sqlmodel.Session = Depends(get_session), user_id: uuid.UUID = Depends(verify_token)) flip_api.domain.schemas.file.PresignedUploadResponse
Generate a pre-signed POST policy for uploading model files to S3.
The returned policy bakes a hard size cap (
MAX_MODEL_FILE_BYTES) into the upload — S3 rejects oversized payloads at the edge, so an authenticated researcher cannot use this endpoint to drive arbitrary storage growth.- Parameters:
model_id (UUID) – The ID of the model to which the file will be uploaded.
body (UploadFileBody) – The request body containing the file name and optionally a Content-Type to lock into the policy.
db (Session) – Database session dependency.
user_id (UUID) – ID of the authenticated user.
- Returns:
url+fieldsfor a multipart/form-data POST plus themaxBytescap so the client can validate locally.- Return type:
- Raises:
HTTPException – If the user is not allowed, if the model does not exist or is marked as deleted, or if there is an error generating the policy.