@@ -2006,6 +2006,8 @@ def list_objects(
2006
2006
use_api_v1 : bool = False ,
2007
2007
use_url_encoding_type : bool = True ,
2008
2008
fetch_owner : bool = False ,
2009
+ extra_headers : DictType | None = None ,
2010
+ extra_query_params : DictType | None = None ,
2009
2011
):
2010
2012
"""
2011
2013
Lists object information of a bucket.
@@ -2021,6 +2023,8 @@ def list_objects(
2021
2023
:param use_api_v1: Flag to control to use ListObjectV1 S3 API or not.
2022
2024
:param use_url_encoding_type: Flag to control whether URL encoding type
2023
2025
to be used or not.
2026
+ :param extra_headers: Extra HTTP headers for advanced usage.
2027
+ :param extra_query_params: Extra query parameters for advanced usage.
2024
2028
:return: Iterator of :class:`Object <Object>`.
2025
2029
2026
2030
Example::
@@ -2065,6 +2069,8 @@ def list_objects(
2065
2069
include_version = include_version ,
2066
2070
encoding_type = "url" if use_url_encoding_type else None ,
2067
2071
fetch_owner = fetch_owner ,
2072
+ extra_headers = extra_headers ,
2073
+ extra_query_params = extra_query_params ,
2068
2074
)
2069
2075
2070
2076
def stat_object (
@@ -3136,6 +3142,8 @@ def _list_objects(
3136
3142
version_id_marker : str | None = None , # versioned
3137
3143
use_api_v1 : bool = False ,
3138
3144
include_version : bool = False ,
3145
+ extra_headers : DictType | None = None ,
3146
+ extra_query_params : DictType | None = None ,
3139
3147
) -> Iterator [Object ]:
3140
3148
"""
3141
3149
List objects optionally including versions.
@@ -3152,7 +3160,7 @@ def _list_objects(
3152
3160
3153
3161
is_truncated = True
3154
3162
while is_truncated :
3155
- query = {}
3163
+ query = extra_query_params or {}
3156
3164
if include_version :
3157
3165
query ["versions" ] = ""
3158
3166
elif not use_api_v1 :
@@ -3184,6 +3192,7 @@ def _list_objects(
3184
3192
"GET" ,
3185
3193
bucket_name ,
3186
3194
query_params = cast (DictType , query ),
3195
+ headers = extra_headers ,
3187
3196
)
3188
3197
3189
3198
objects , is_truncated , start_after , version_id_marker = (
0 commit comments