flip_api.file_services.presigned_url_for_upload

Attributes

router

Functions

get_presigned_url_for_upload(, user_id)

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 + fields for a multipart/form-data POST plus the maxBytes cap so the client can validate locally.

Return type:

PresignedUploadResponse

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.