Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 19f1816

Browse files
author
Dani Reinón
committed
fix: parity with js
1 parent 8a89dbb commit 19f1816

File tree

4 files changed

+20
-44
lines changed

4 files changed

+20
-44
lines changed

storage3/_async/client.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
from __future__ import annotations
22

3-
from typing import Union
4-
5-
from httpx import Timeout
6-
73
from ..utils import AsyncClient, __version__
84
from .bucket import AsyncStorageBucketAPI
95
from .file_api import AsyncBucketProxy
@@ -19,28 +15,23 @@ class AsyncStorageClient(AsyncStorageBucketAPI):
1915
def __init__(
2016
self,
2117
url: str,
22-
key: str,
23-
headers: dict[str, str] = None,
24-
timeout: Union[int, float, Timeout] = 5,
18+
headers: dict[str, str],
2519
) -> None:
2620
headers = {
2721
"User-Agent": f"supabase-py/storage3 v{__version__}",
28-
**self._get_auth_headers(key),
29-
**(headers or {}),
22+
**headers,
3023
}
31-
self.session = self.create_session(url, headers, timeout)
24+
self.session = self.create_session(url, headers)
3225
super().__init__(self.session)
3326

3427
def create_session(
3528
self,
3629
base_url: str,
3730
headers: dict[str, str],
38-
timeout: Union[int, float, Timeout],
3931
) -> AsyncClient:
4032
return AsyncClient(
4133
base_url=base_url,
4234
headers=headers,
43-
timeout=timeout,
4435
)
4536

4637
async def __aenter__(self) -> AsyncStorageClient:
@@ -61,12 +52,3 @@ def from_(self, id: str) -> AsyncBucketProxy:
6152
The unique identifier of the bucket
6253
"""
6354
return AsyncBucketProxy(id, self._client)
64-
65-
@staticmethod
66-
def _get_auth_headers(key: str) -> dict[str, str]:
67-
"""Helper method to get auth headers."""
68-
# What's the corresponding method to get the token
69-
return {
70-
"apiKey": key,
71-
"Authorization": f"Bearer {key}",
72-
}

storage3/_sync/client.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
from __future__ import annotations
22

3-
from typing import Union
4-
5-
from httpx import Timeout
6-
73
from ..utils import SyncClient, __version__
84
from .bucket import SyncStorageBucketAPI
95
from .file_api import SyncBucketProxy
@@ -19,28 +15,23 @@ class SyncStorageClient(SyncStorageBucketAPI):
1915
def __init__(
2016
self,
2117
url: str,
22-
key: str,
23-
headers: dict[str, str] = None,
24-
timeout: Union[int, float, Timeout] = 5,
18+
headers: dict[str, str],
2519
) -> None:
2620
headers = {
2721
"User-Agent": f"supabase-py/storage3 v{__version__}",
28-
**self._get_auth_headers(key),
29-
**(headers or {}),
22+
**headers,
3023
}
31-
self.session = self.create_session(url, headers, timeout)
24+
self.session = self.create_session(url, headers)
3225
super().__init__(self.session)
3326

3427
def create_session(
3528
self,
3629
base_url: str,
3730
headers: dict[str, str],
38-
timeout: Union[int, float, Timeout],
3931
) -> SyncClient:
4032
return SyncClient(
4133
base_url=base_url,
4234
headers=headers,
43-
timeout=timeout,
4435
)
4536

4637
def __enter__(self) -> SyncStorageClient:
@@ -61,12 +52,3 @@ def from_(self, id: str) -> SyncBucketProxy:
6152
The unique identifier of the bucket
6253
"""
6354
return SyncBucketProxy(id, self._client)
64-
65-
@staticmethod
66-
def _get_auth_headers(key: str) -> dict[str, str]:
67-
"""Helper method to get auth headers."""
68-
# What's the corresponding method to get the token
69-
return {
70-
"apiKey": key,
71-
"Authorization": f"Bearer {key}",
72-
}

tests/_async/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ async def storage() -> AsyncStorageClient:
2525
assert url is not None, "Must provide SUPABASE_TEST_URL environment variable"
2626
key = os.environ.get("SUPABASE_TEST_KEY")
2727
assert key is not None, "Must provide SUPABASE_TEST_KEY environment variable"
28-
async with AsyncStorageClient(url, key) as client:
28+
async with AsyncStorageClient(
29+
url,
30+
{
31+
"apiKey": key,
32+
"Authorization": f"Bearer {key}",
33+
},
34+
) as client:
2935
yield client

tests/_sync/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ def storage() -> SyncStorageClient:
2525
assert url is not None, "Must provide SUPABASE_TEST_URL environment variable"
2626
key = os.environ.get("SUPABASE_TEST_KEY")
2727
assert key is not None, "Must provide SUPABASE_TEST_KEY environment variable"
28-
with SyncStorageClient(url, key) as client:
28+
with SyncStorageClient(
29+
url,
30+
{
31+
"apiKey": key,
32+
"Authorization": f"Bearer {key}",
33+
},
34+
) as client:
2935
yield client

0 commit comments

Comments
 (0)