Skip to content

get_object_torrent

get_object_torrent(
    bucket: BucketName,
    key: ObjectKey,
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    request_payer: Optional[RequestPayer] = None,
    expected_bucket_owner: Optional[AccountId] = None,
) -> Generator[GetObjectTorrentOutput]

This operation is not supported for directory buckets.

Returns torrent files from a bucket. BitTorrent can save you bandwidth when you're distributing large files.

You can get torrent only for objects that are less than 5 GB in size, and that are not encrypted using server-side encryption with a customer-provided encryption key.

To use GET, you must have READ access to the object.

This functionality is not supported for Amazon S3 on Outposts.

The following action is related to GetObjectTorrent:

You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

Parameters:

  • bucket (BucketName) –

    The name of the bucket containing the object for which to get the torrent files.

  • key (ObjectKey) –

    The object key for which to get the information.

  • expected_bucket_owner (Optional[AccountId], default: None ) –

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

Raises:

Examples:

To retrieve torrent files for an object The following example retrieves torrent files of an object.

>>> client.get_object_torrent(bucket='examplebucket', key='HappyFace.jpg')
Source code in docs_src/capo_s3/_services/s3.py
@contextmanager
def get_object_torrent(
    self,
    bucket: "capo_s3.types.bucket_name.BucketName",
    key: "capo_s3.types.object_key.ObjectKey",
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    request_payer: Optional["capo_s3.types.request_payer.RequestPayer"] = None,
    expected_bucket_owner: Optional["capo_s3.types.account_id.AccountId"] = None,
) -> "Generator[capo_s3.types.get_object_torrent_output.GetObjectTorrentOutput]":
    """<note> <p>This operation is not supported for directory buckets.</p> </note> <p>Returns torrent files from a bucket. BitTorrent can save you bandwidth when you're distributing large files.</p> <note> <p>You can get torrent only for objects that are less than 5 GB in size, and that are not encrypted using server-side encryption with a customer-provided encryption key.</p> </note> <p>To use GET, you must have READ access to the object.</p> <p>This functionality is not supported for Amazon S3 on Outposts.</p> <p>The following action is related to <code>GetObjectTorrent</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html">GetObject</a> </p> </li> </ul> <important> <p>You must URL encode any signed header values that contain spaces. For example, if your header value is <code>my file.txt</code>, containing two spaces after <code>my</code>, you must URL encode this value to <code>my%20%20file.txt</code>.</p> </important>

    Args:
        bucket: <p>The name of the bucket containing the object for which to get the torrent files.</p>
        key: <p>The object key for which to get the information.</p>
        expected_bucket_owner: <p>The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code <code>403 Forbidden</code> (access denied).</p>

    Raises:
        capo_s3.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To retrieve torrent files for an object
        The following example retrieves torrent files of an object.

        >>> client.get_object_torrent(bucket='examplebucket', key='HappyFace.jpg')
    """

    def _handler(
        req: "OperationRequest[capo_s3.types.get_object_torrent_request.GetObjectTorrentRequest]",
    ) -> OperationResponse[
        "capo_s3.types.get_object_torrent_output.GetObjectTorrentOutput"
    ]:
        import capo_s3._operations.amazon_s3.get_object_torrent

        output, http_response = (
            capo_s3._operations.amazon_s3.get_object_torrent.get_object_torrent(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_s3.types.get_object_torrent_output.GetObjectTorrentOutput",
    ) -> dict[str, Any]:
        import capo_s3.types.get_object_torrent_output

        return capo_s3.types.get_object_torrent_output.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetObjectTorrent", redact_output=_redact_output),
    )
    input_: capo_s3.types.get_object_torrent_request.GetObjectTorrentRequest = {
        "bucket": bucket,
        "key": key,
    }
    if request_payer is not None:
        input_["request_payer"] = request_payer
    if expected_bucket_owner is not None:
        input_["expected_bucket_owner"] = expected_bucket_owner

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    try:
        yield response.output
    finally:
        response.response.close()