biodm.components.services.s3service module

class S3Service(app, table: Type[Base], *args, **kwargs)

Bases: CompositeEntityService

Class for automatic management of S3 bucket transactions for file resources.

async complete_multipart(**kwargs)
async download(**kwargs) str

Get File entry from DB, and return a direct download url.

Parameters:
  • pk_val (List[Any]) – key

  • user_info (UserInfo | None) – requesting user info

  • session (AsyncSession) – current db session

Raises:

FileNotUploadedError – File entry exists but has not been validated yet

Returns:

direct download url.

Return type:

str

async gen_key(item: S3File, session: AsyncSession) str

Generate a unique bucket key from file elements.

Parameters:
  • item (S3File) – file

  • session (AsyncSession) – current sqla session

Returns:

unique s3 bucket file key

Return type:

str

async gen_upload_form(file: S3File, session: AsyncSession)

Populates an Upload for a newly created file. Handling simple post and multipart_upload cases.

Parameters:
  • file (S3File) – New file

  • session (AsyncSession) – current session

property key_fields: List[str]

List of fields used to compute the key.

post_upload_callback: Path
async release(**kwargs) Base
s3() S3Manager