Skip to content

Commit

Permalink
Update rx.get_upload_url signature to accept Var[str] (#4826)
Browse files Browse the repository at this point in the history
* Update rx.get_upload_url signature to accept Var[str]

* Add py.typed

Fix #4806
  • Loading branch information
masenf authored Feb 15, 2025
1 parent 10bae95 commit 6848915
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions reflex/components/core/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_upload_dir() -> Path:
).to(str)


def get_upload_url(file_path: str) -> Var[str]:
def get_upload_url(file_path: str | Var[str]) -> Var[str]:
"""Get the URL of an uploaded file.
Args:
Expand All @@ -158,7 +158,7 @@ def get_upload_url(file_path: str) -> Var[str]:
"""
Upload.is_used = True

return uploaded_files_url_prefix + "/" + file_path
return Var.create(f"{uploaded_files_url_prefix}/{file_path}")


def _on_drop_spec(files: Var) -> Tuple[Var[Any]]:
Expand Down
2 changes: 1 addition & 1 deletion reflex/components/core/upload.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ uploaded_files_url_prefix = Var(
),
).to(str)

def get_upload_url(file_path: str) -> Var[str]: ...
def get_upload_url(file_path: str | Var[str]) -> Var[str]: ...

class UploadFilesProvider(Component):
@overload
Expand Down
Empty file added reflex/py.typed
Empty file.

0 comments on commit 6848915

Please # to comment.