Browse Source

Update rx.get_upload_url signature to accept Var[str] (#4826)

* Update rx.get_upload_url signature to accept Var[str]

* Add py.typed

Fix #4806
Masen Furer 3 months ago
parent
commit
6848915883
3 changed files with 3 additions and 3 deletions
  1. 2 2
      reflex/components/core/upload.py
  2. 1 1
      reflex/components/core/upload.pyi
  3. 0 0
      reflex/py.typed

+ 2 - 2
reflex/components/core/upload.py

@@ -147,7 +147,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]:
     """Get the URL of an uploaded file.
 
     Args:
@@ -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]]:

+ 1 - 1
reflex/components/core/upload.pyi

@@ -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

+ 0 - 0
reflex/py.typed