Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra headers to stat_object() API #1335

Merged
merged 8 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ __Parameters__
| `object_name` | _str_ | Object name in the bucket. |
| `ssec` | _SseCustomerKey_ | Server-side encryption customer key. |
| `version_id` | _str_ | Version ID of the object. |
| `extra_headers` | _dict_ | Any additional headers to be added with GET request. |
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
| `extra_query_params` | _dict_ | Extra query parameters for advanced usage. |

__Return Value__
Expand Down
6 changes: 5 additions & 1 deletion minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,14 +1854,15 @@ def list_objects(self, bucket_name, prefix=None, recursive=False,
)

def stat_object(self, bucket_name, object_name, ssec=None, version_id=None,
extra_query_params=None):
extra_headers=None, extra_query_params=None):
"""
Get object information and metadata of an object.

:param bucket_name: Name of the bucket.
:param object_name: Object name in the bucket.
:param ssec: Server-side encryption customer key.
:param version_id: Version ID of the object.
:param extra_headers: Additional headers to be added with GET request.
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
:param extra_query_params: Extra query parameters for advanced usage.
:return: :class:`Object <Object>`.

Expand All @@ -1887,6 +1888,9 @@ def stat_object(self, bucket_name, object_name, ssec=None, version_id=None,
check_ssec(ssec)

headers = ssec.headers() if ssec else {}
if extra_headers:
headers.update(extra_headers)

query_params = extra_query_params or {}
query_params.update({"versionId": version_id} if version_id else {})
response = self._execute(
Expand Down