Skip to content

S3Client#

Index > S3 > S3Client

Auto-generated documentation for S3 type annotations stubs module mypy-boto3-s3.

S3Client#

Type annotations and code completion for boto3.client("s3"). boto3 documentation

# S3Client usage example

from boto3.session import Session
from mypy_boto3_s3.client import S3Client

def get_s3_client() -> S3Client:
    return Session().client("s3")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("s3").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("s3")

try:
    do_something(client)
except (
    client.exceptions.BucketAlreadyExists,
    client.exceptions.BucketAlreadyOwnedByYou,
    client.exceptions.ClientError,
    client.exceptions.InvalidObjectState,
    client.exceptions.NoSuchBucket,
    client.exceptions.NoSuchKey,
    client.exceptions.NoSuchUpload,
    client.exceptions.ObjectAlreadyInActiveTierError,
    client.exceptions.ObjectNotInActiveTierError,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_s3.client import Exceptions

def handle_error(exc: Exceptions.BucketAlreadyExists) -> None:
    ...

Methods#

abort_multipart_upload#

This operation aborts a multipart upload.

Type annotations and code completion for boto3.client("s3").abort_multipart_upload method. boto3 documentation

# abort_multipart_upload method definition

def abort_multipart_upload(
    self,
    *,
    Bucket: str,
    Key: str,
    UploadId: str,
    RequestPayer: RequestPayerType = ...,  # (1)
    ExpectedBucketOwner: str = ...,
) -> AbortMultipartUploadOutputTypeDef:  # (2)
    ...
  1. See RequestPayerType
  2. See AbortMultipartUploadOutputTypeDef
# abort_multipart_upload method usage example with argument unpacking

kwargs: AbortMultipartUploadRequestRequestTypeDef = {  # (1)
    "Bucket": ...,
    "Key": ...,
    "UploadId": ...,
}

parent.abort_multipart_upload(**kwargs)
  1. See AbortMultipartUploadRequestRequestTypeDef

can_paginate#

Check if an operation can be paginated.

Type annotations and code completion for boto3.client("s3").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

close#

Closes underlying endpoint connections.

Type annotations and code completion for boto3.client("s3").close method. boto3 documentation

# close method definition

def close(
    self,
) -> None:
    ...

complete_multipart_upload#

Completes a multipart upload by assembling previously uploaded parts.

Type annotations and code completion for boto3.client("s3").complete_multipart_upload method. boto3 documentation

# complete_multipart_upload method definition

def complete_multipart_upload(
    self,
    *,
    Bucket: str,
    Key: str,
    UploadId: str,
    MultipartUpload: CompletedMultipartUploadTypeDef = ...,  # (1)
    ChecksumCRC32: str = ...,
    ChecksumCRC32C: str = ...,
    ChecksumSHA1: str = ...,
    ChecksumSHA256: str = ...,
    RequestPayer: RequestPayerType = ...,  # (2)
    ExpectedBucketOwner: str = ...,
    SSECustomerAlgorithm: str = ...,
    SSECustomerKey: str = ...,
    SSECustomerKeyMD5: str = ...,
) -> CompleteMultipartUploadOutputTypeDef:  # (3)
    ...
  1. See CompletedMultipartUploadTypeDef
  2. See RequestPayerType
  3. See CompleteMultipartUploadOutputTypeDef
# complete_multipart_upload method usage example with argument unpacking

kwargs: CompleteMultipartUploadRequestRequestTypeDef = {  # (1)
    "Bucket": ...,
    "Key": ...,
    "UploadId": ...,
}

parent.complete_multipart_upload(**kwargs)
  1. See CompleteMultipartUploadRequestRequestTypeDef

copy#

Copy an object from one S3 location to another.

Type annotations and code completion for boto3.client("s3").copy method. boto3 documentation

# copy method definition

def copy(
    self,
    CopySource: CopySourceTypeDef,  # (1)
    Bucket: str,
    Key: str,
    ExtraArgs: Optional[Dict[str, Any]] = ...,
    Callback: Optional[Callable[..., Any]] = ...,
    SourceClient: Optional[BaseClient] = ...,
    Config: Optional[TransferConfig] = ...,
) -> None:
    ...
  1. See CopySourceTypeDef
# copy method usage example with argument unpacking

kwargs: ClientCopyRequestTypeDef = {  # (1)
    "CopySource": ...,
    "Bucket": ...,
    "Key": ...,
}

parent.copy(**kwargs)
  1. See ClientCopyRequestTypeDef

copy_object#

Creates a copy of an object that is already stored in Amazon S3.

Type annotations and code completion for boto3.client("s3").copy_object method. boto3 documentation

# copy_object method definition

def copy_object(
    self,
    *,
    Bucket: str,
    CopySource: Union[str, CopySourceTypeDef],  # (1)
    Key: str,
    ACL: ObjectCannedACLType = ...,  # (2)
    CacheControl: str = ...,
    ChecksumAlgorithm: ChecksumAlgorithmType = ...,  # (3)
    ContentDisposition: str = ...,
    ContentEncoding: str = ...,
    ContentLanguage: str = ...,
    ContentType: str = ...,
    CopySourceIfMatch: str = ...,
    CopySourceIfModifiedSince