Skip to content

Commit

Permalink
fix: update render_path for get_public_url
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 8, 2023
1 parent 42a9ed3 commit 0272f1b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions storage3/_async/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ async def get_public_url(self, path: str, options: TransformOptions = {}) -> str
file path, including the path and file name. For example `folder/image.png`.
"""
render_path = (
"render/image/authenticated" if options.get("transform") else "object"
"render/image" if options.get("transform") else "object"
)
transformation_query = urllib.parse.urlencode(options)
query_string = f"/?{transformation_query}" if transformation_query else ""
_path = self._get_final_path(path)
return f"{self._client.base_url}{render_path}/public/{_path}{query_string}"
return f"{self._client.base_url}{render_path}/public{_path}{query_string}"

async def move(self, from_path: str, to_path: str) -> dict[str, str]:
"""
Expand Down
2 changes: 1 addition & 1 deletion storage3/_sync/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from httpx import HTTPError, Response

from ..types import RequestMethod
from ..utils import StorageException, SyncClient
from ..utils import SyncClient, StorageException
from .file_api import SyncBucket

__all__ = ["SyncStorageBucketAPI"]
Expand Down
6 changes: 3 additions & 3 deletions storage3/_sync/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
RequestMethod,
TransformOptions,
)
from ..utils import StorageException, SyncClient
from ..utils import SyncClient, StorageException

__all__ = ["SyncBucket"]

Expand Down Expand Up @@ -82,12 +82,12 @@ def get_public_url(self, path: str, options: TransformOptions = {}) -> str:
file path, including the path and file name. For example `folder/image.png`.
"""
render_path = (
"render/image/authenticated" if options.get("transform") else "object"
"render/image" if options.get("transform") else "object"
)
transformation_query = urllib.parse.urlencode(options)
query_string = f"/?{transformation_query}" if transformation_query else ""
_path = self._get_final_path(path)
return f"{self._client.base_url}{render_path}/public/{_path}{query_string}"
return f"{self._client.base_url}{render_path}/public{_path}{query_string}"

def move(self, from_path: str, to_path: str) -> dict[str, str]:
"""
Expand Down
4 changes: 3 additions & 1 deletion tests/_sync/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def bucket(storage: SyncStorageClient, uuid_factory: Callable[[], str]) -> str:


@pytest.fixture(scope="module")
def public_bucket(storage: SyncStorageClient, uuid_factory: Callable[[], str]) -> str:
def public_bucket(
storage: SyncStorageClient, uuid_factory: Callable[[], str]
) -> str:
"""Creates a test public bucket which will be used in the whole storage tests run and deleted at the end"""
bucket_id = uuid_factory()

Expand Down

0 comments on commit 0272f1b

Please sign in to comment.