Skip to content

Commit c90ad3f

Browse files
committed
fix(storage): add query parameters option to download
1 parent 8757f23 commit c90ad3f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/storage/src/storage3/_async/file_api.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dataclasses import dataclass, field
77
from io import BufferedReader, FileIO
88
from pathlib import Path
9-
from typing import Any, List, Literal, Optional, Union, cast
9+
from typing import Any, Dict, List, Literal, Optional, Union, cast
1010

1111
from httpx import AsyncClient, Headers, HTTPStatusError, Response
1212
from yarl import URL
@@ -439,7 +439,10 @@ async def list(
439439
return response.json()
440440

441441
async def download(
442-
self, path: str, options: Optional[DownloadOptions] = None
442+
self,
443+
path: str,
444+
options: Optional[DownloadOptions] = None,
445+
query_params: Optional[Dict[str, str]] = None,
443446
) -> bytes:
444447
"""
445448
Downloads a file.
@@ -449,20 +452,20 @@ async def download(
449452
path
450453
The file path to be downloaded, including the path and file name. For example `folder/image.png`.
451454
"""
452-
url_options = options or {}
455+
url_options = options or DownloadOptions()
453456
render_path = (
454457
["render", "image", "authenticated"]
455458
if url_options.get("transform")
456459
else ["object"]
457460
)
458461

459-
transform_options = url_options.get("transform") or {}
462+
transform_options = url_options.get("transform") or TransformOptions()
460463

461464
path_parts = relative_path_to_parts(path)
462465
response = await self._request(
463466
"GET",
464467
[*render_path, self.id, *path_parts],
465-
query_params=transform_to_dict(transform_options),
468+
query_params={**transform_to_dict(transform_options), **query_params},
466469
)
467470
return response.content
468471

0 commit comments

Comments
 (0)