awswrangler.s3.does_object_exist¶
- awswrangler.s3.does_object_exist(path: str, s3_additional_kwargs: dict[str, Any] | None = None, boto3_session: Session | None = None, version_id: str | None = None) bool ¶
Check if object exists on S3.
- Parameters:
path (
str
) – S3 path (e.g. s3://bucket/key).s3_additional_kwargs (
dict
[str
,Any
] |None
) – Forwarded to botocore requests. e.g. s3_additional_kwargs={‘RequestPayer’: ‘requester’}boto3_session (
Session
|None
) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.version_id (
str
|None
) – Specific version of the object that should exist.
- Return type:
bool
- Returns:
True if exists, False otherwise.
Examples
Using the default boto3 session
>>> import awswrangler as wr >>> wr.s3.does_object_exist('s3://bucket/key_real') True >>> wr.s3.does_object_exist('s3://bucket/key_unreal') False
Using a custom boto3 session
>>> import boto3 >>> import awswrangler as wr >>> wr.s3.does_object_exist('s3://bucket/key_real', boto3_session=boto3.Session()) True >>> wr.s3.does_object_exist('s3://bucket/key_unreal', boto3_session=boto3.Session()) False