Return the metadata of the path. Args: path: S3 path (s3://bucket/key) to get metadata for. **kwargs: Additional parameters passed to the HeadObject API. Returns: S3Metadata, which behaves as a read-only mapping of the user-defined me
(self, path: str, **kwargs)
| 1416 | ) |
| 1417 | |
| 1418 | def metadata(self, path: str, **kwargs) -> S3Metadata: |
| 1419 | """Return the metadata of the path. |
| 1420 | |
| 1421 | Args: |
| 1422 | path: S3 path (s3://bucket/key) to get metadata for. |
| 1423 | **kwargs: Additional parameters passed to the HeadObject API. |
| 1424 | |
| 1425 | Returns: |
| 1426 | S3Metadata, which behaves as a read-only mapping of the |
| 1427 | user-defined metadata (``x-amz-meta-*``) and exposes the |
| 1428 | system-defined metadata (content type, encryption settings, |
| 1429 | etc.) as typed properties. |
| 1430 | """ |
| 1431 | bucket, key, version_id = self.parse_path(path) |
| 1432 | if not key: |
| 1433 | raise ValueError("Cannot get metadata of a bucket.") |
| 1434 | request: dict[str, Any] = {"Bucket": bucket, "Key": key} |
| 1435 | if version_id: |
| 1436 | request.update({"VersionId": version_id}) |
| 1437 | |
| 1438 | _logger.debug(f"Head object metadata: s3://{bucket}/{key}?versionId={version_id}") |
| 1439 | response = self._call( |
| 1440 | self._client.head_object, |
| 1441 | **request, |
| 1442 | **kwargs, |
| 1443 | ) |
| 1444 | return S3Metadata(response) |
| 1445 | |
| 1446 | def getxattr(self, path: str, attr_name: str, **kwargs) -> str | None: |
| 1447 | """Get an attribute from the user-defined metadata of the path. |
no test coverage detected