Skip to content

Client.uploads¤

abort_multipart_upload ¤

abort_multipart_upload(
    *, pk: str, s3_upload_id: str
) -> gcapi.models.UserUpload

Abort a multipart upload session.

Parameters:

  • pk (str) –

    Primary key of the upload session.

  • s3_upload_id (str) –

    S3 multipart upload identifier to abort.

Returns:

  • UserUpload

    Patched upload after aborting the multipart upload.

complete_multipart_upload ¤

complete_multipart_upload(
    *, pk: str, s3_upload_id: str, parts: list
) -> gcapi.models.UserUploadComplete

Complete a multipart upload session.

Parameters:

  • pk (str) –

    Primary key of the upload session.

  • s3_upload_id (str) –

    S3 multipart upload identifier.

  • parts (list) –

    List of completed parts with ETag and PartNumber.

Returns:

create ¤

create(*, filename: str | Path) -> gcapi.models.UserUpload

Create a new upload session.

Parameters:

  • filename (str | Path) –

    Name of the file to be uploaded.

Returns:

  • UserUpload

    The created upload session model instance.

detail ¤

detail(
    pk: str | None = None,
    api_url: str | None = None,
    **params: Any
) -> T

Retrieve a specific resource by primary key, URL, or search parameters.

Parameters:

  • pk (str | None, default: None ) –

    Primary key of the resource to retrieve.

  • api_url (str | None, default: None ) –

    Direct API URL of the resource to retrieve.

  • **params (Any, default: {} ) –

    Search parameters to find a unique resource, such as slug="your-slug".

Returns:

  • T

    The requested resource instance.

Raises:

  • ValueError

    If more than one or none of pk, api_url, or params are specified.

  • ObjectNotFound

    If no resource is found matching the criteria.

  • MultipleObjectsReturned

    If multiple resources match the search parameters.

generate_presigned_urls ¤

generate_presigned_urls(
    *, pk: str, s3_upload_id: str, part_numbers: list[int]
) -> gcapi.models.UserUploadPresignedURLs

Generate presigned URLs for multipart upload parts.

Parameters:

  • pk (str) –

    Primary key of the upload session.

  • s3_upload_id (str) –

    S3 multipart upload identifier.

  • part_numbers (list[int]) –

    List of part numbers to generate URLs for.

iterate_all ¤

iterate_all(
    params: dict[str, Any] | None = None,
) -> Iterator[T]

Iterate through all resources from the API endpoint across all pages.

This method automatically handles pagination and yields individual resources from all pages until all resources have been retrieved.

Parameters:

  • params (dict[str, Any] | None, default: None ) –

    Query parameters to include in the API requests.

Yields:

  • T

    Individual resources from the API endpoint.

list_parts ¤

list_parts(
    *, pk: str, s3_upload_id: str
) -> gcapi.models.UserUploadParts

List parts of a multipart upload.

Parameters:

  • pk (str) –

    Primary key of the upload session.

  • s3_upload_id (str) –

    S3 multipart upload identifier.

Returns:

page ¤

page(
    offset: int = 0,
    limit: int = 100,
    params: dict[str, Any] | None = None,
) -> PageResult[T]

Retrieve a paginated set of resources from the API endpoint.

Parameters:

  • offset (int, default: 0 ) –

    The starting index for pagination (zero-based).

  • limit (int, default: 100 ) –

    The maximum number of results to return in this page.

  • params (dict[str, Any] | None, default: None ) –

    Additional query parameters to include in the API request.

Returns:

  • PageResult[T]

    A paginated result containing the requested resources and metadata.

upload_fileobj ¤

upload_fileobj(
    *, fileobj: ReadableBuffer, filename: str
) -> gcapi.models.UserUploadComplete

Upload a file object using multipart upload.

Parameters:

  • fileobj (ReadableBuffer) –

    File object to upload

  • filename (str) –

    Name of the file being uploaded.

Returns:

Raises:

  • Exception

    If upload fails, the multipart upload is aborted and exception is re-raised.

upload_multiple_fileobj ¤

upload_multiple_fileobj(
    *,
    file_objects: Sequence[ReadableBuffer],
    filenames: Sequence[str]
) -> list[gcapi.models.UserUploadComplete]

Upload multiple files concurrently using a thread pool.

Parameters:

  • file_objects (Sequence[ReadableBuffer]) –

    List of file objects to upload.

  • filenames (Sequence[str]) –

    List of filenames corresponding to the file objects.

Returns: