@@ -283,6 +283,45 @@ async def test_client_upload(
283283 assert image_info .get ("metadata" , {}).get ("mimetype" ) == file .mime_type
284284
285285
286+ async def test_client_upload_with_query (
287+ storage_file_client : AsyncBucketProxy , file : FileForTesting
288+ ) -> None :
289+ """Ensure we can upload files to a bucket, even with query parameters"""
290+ await storage_file_client .upload (
291+ file .bucket_path , file .local_path , {"content-type" : file .mime_type }
292+ )
293+
294+ image = await storage_file_client .download (
295+ file .bucket_path , query_params = {"my-param" : "test" }
296+ )
297+ files = await storage_file_client .list (file .bucket_folder )
298+ image_info = next ((f for f in files if f .get ("name" ) == file .name ), None )
299+
300+ assert image == file .file_content
301+ assert image_info is not None
302+ assert image_info .get ("metadata" , {}).get ("mimetype" ) == file .mime_type
303+
304+
305+ async def test_client_download_with_query_doesnt_lose_params (
306+ storage_file_client : AsyncBucketProxy , file : FileForTesting
307+ ) -> None :
308+ """Ensure query params aren't lost"""
309+ from yarl import URL
310+
311+ params = {"my-param" : "test" }
312+ mock_response = Mock ()
313+ with patch .object (HttpxClient , "request" ) as mock_request :
314+ mock_request .return_value = mock_response
315+ await storage_file_client .download (file .bucket_path , query_params = params )
316+ expected_url = storage_file_client ._base_url .joinpath (
317+ "object" , storage_file_client .id , * URL (file .bucket_path ).parts
318+ ).with_query (params )
319+ actual_url = mock_request .call_args [0 ][1 ]
320+
321+ assert URL (actual_url ).query == params
322+ assert str (expected_url ) == actual_url
323+
324+
286325async def test_client_update (
287326 storage_file_client : AsyncBucketProxy ,
288327 two_files : list [FileForTesting ],
0 commit comments