exists#
Tagging related API.
- class s3pathlib.core.exists.ExistsAPIMixin[source]#
A mixin class that implements the exists test related methods.
- exists(version_id: str = Sentinel('NOTHING'), bsm: BotoSesManager | None = None) bool [source]#
Test if an S3Path object actually exists in S3 bucket.
- For S3 bucket: check if the bucket exists. If you don’t have the
access, then it raise exception.
For S3 object: check if the object exists
- For S3 directory: check if the directory exists, it returns
True
even if the folder doesn’t have any object.
- For S3 directory: check if the directory exists, it returns
- For versioning enabled bucket, you can explicitly check if a specific
version exists, otherwise it will check the latest version.
Example:
>>> S3Path("bucket").exists() >>> S3Path("bucket/file.txt").exists() >>> S3Path("bucket/folder/").exists() >>> S3Path("bucket/file.txt").exists(version_id="v123456")
New in version 1.0.1.
Changed in version 2.0.1: Add
version_id
parameter.