Skip to content

Commit

Permalink
Added extra request headers capabilities to stat_object
Browse files Browse the repository at this point in the history
  • Loading branch information
trollfot committed Nov 17, 2023
1 parent 8e681bb commit ff6c4bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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. |
| `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):
"""
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:
headers.update(request_headers)

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

0 comments on commit ff6c4bb

Please sign in to comment.