diff --git a/storage3/_async/file_api.py b/storage3/_async/file_api.py index effaf52f..c459e989 100644 --- a/storage3/_async/file_api.py +++ b/storage3/_async/file_api.py @@ -176,8 +176,13 @@ async def create_signed_url( json=json, ) data = response.json() + + # Prepare URL + url = urllib.parse.urlparse(data["signedURL"]) + url = urllib.parse.quote(url.path) + f"?{url.query}" + data["signedURL"] = ( - f"{self._client.base_url}{cast(str, data['signedURL']).lstrip('/')}{download_query}" + f"{self._client.base_url}{cast(str, url).lstrip('/')}{download_query}" ) return data @@ -212,8 +217,13 @@ async def create_signed_urls( ) data = response.json() for item in data: + + # Prepare URL + url = urllib.parse.urlparse(item["signedURL"]) + url = urllib.parse.quote(url.path) + f"?{url.query}" + item["signedURL"] = ( - f"{self._client.base_url}{cast(str, item['signedURL']).lstrip('/')}{download_query}" + f"{self._client.base_url}{cast(str, url).lstrip('/')}{download_query}" ) return data diff --git a/storage3/_sync/file_api.py b/storage3/_sync/file_api.py index 3e63a8af..a6f96bc2 100644 --- a/storage3/_sync/file_api.py +++ b/storage3/_sync/file_api.py @@ -176,8 +176,13 @@ def create_signed_url( json=json, ) data = response.json() + + # Prepare URL + url = urllib.parse.urlparse(data["signedURL"]) + url = urllib.parse.quote(url.path) + f"?{url.query}" + data["signedURL"] = ( - f"{self._client.base_url}{cast(str, data['signedURL']).lstrip('/')}{download_query}" + f"{self._client.base_url}{cast(str, url).lstrip('/')}{download_query}" ) return data @@ -212,8 +217,13 @@ def create_signed_urls( ) data = response.json() for item in data: + + # Prepare URL + url = urllib.parse.urlparse(item["signedURL"]) + url = urllib.parse.quote(url.path) + f"?{url.query}" + item["signedURL"] = ( - f"{self._client.base_url}{cast(str, item['signedURL']).lstrip('/')}{download_query}" + f"{self._client.base_url}{cast(str, url).lstrip('/')}{download_query}" ) return data