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 2 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. |
| `request_headers` | _dict_ | Any additional headers to be added with GET request. |
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 @@ -1853,14 +1853,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):
request_headers=None, extra_query_params=None):
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
"""
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 request_headers: Any additional headers to be added with GET request.
:param extra_query_params: Extra query parameters for advanced usage.
:return: :class:`Object <Object>`.

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

headers = ssec.headers() if ssec else {}
if request_headers:
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
headers.update(request_headers)
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved

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