in iopath/common/s3.py [0:0]
def _head_object(self, path: str) -> Optional[Dict]:
bucket, s3_path = self._parse_uri(path)
client = self._get_client(bucket)
try:
# Raises exception if not exists, else it exists.
response = client.head_object(Bucket=bucket, Key=s3_path)
return response
except botocore.exceptions.ClientError as e:
if e.response["Error"]["Message"] == "Bad Request":
raise OSError(
f"Error in checking s3 path {path} - " f"{type(e).__name__}: {e}"
) from e
return None