From b5f06991a972b5beca754192be2524848758b254 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Tue, 13 Feb 2024 11:09:48 -0800 Subject: [PATCH] Change names to `get_upload_dir` and `get_upload_url` (#2587) These shorter names are more concise and easier to type without losing significant information. --- reflex/app.py | 4 ++-- reflex/components/core/__init__.py | 9 ++++++++- reflex/components/core/upload.py | 4 ++-- reflex/components/core/upload.pyi | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/reflex/app.py b/reflex/app.py index 72632bc15..25d9d07c6 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -47,7 +47,7 @@ from reflex.components.core.client_side_routing import ( Default404Page, wait_for_client_redirect, ) -from reflex.components.core.upload import Upload, get_uploaded_files_dir +from reflex.components.core.upload import Upload, get_upload_dir from reflex.components.radix import themes from reflex.config import get_config from reflex.event import Event, EventHandler, EventSpec @@ -256,7 +256,7 @@ class App(Base): # To access uploaded files. self.api.mount( str(constants.Endpoint.UPLOAD), - StaticFiles(directory=get_uploaded_files_dir()), + StaticFiles(directory=get_upload_dir()), name="uploaded_files", ) diff --git a/reflex/components/core/__init__.py b/reflex/components/core/__init__.py index ba26ecfeb..54acefb55 100644 --- a/reflex/components/core/__init__.py +++ b/reflex/components/core/__init__.py @@ -14,7 +14,14 @@ from .responsive import ( tablet_and_desktop, tablet_only, ) -from .upload import Upload, cancel_upload, clear_selected_files, selected_files +from .upload import ( + Upload, + cancel_upload, + clear_selected_files, + get_upload_dir, + get_upload_url, + selected_files, +) connection_banner = ConnectionBanner.create connection_modal = ConnectionModal.create diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index aadb6fc77..269fd78a0 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -94,7 +94,7 @@ def cancel_upload(upload_id: str) -> EventSpec: return call_script(f"upload_controllers[{upload_id!r}]?.abort()") -def get_uploaded_files_dir() -> Path: +def get_upload_dir() -> Path: """Get the directory where uploaded files are stored. Returns: @@ -119,7 +119,7 @@ uploaded_files_url_prefix: Var = Var.create_safe( ) -def get_uploaded_file_url(file_path: str) -> str: +def get_upload_url(file_path: str) -> str: """Get the URL of an uploaded file. Args: diff --git a/reflex/components/core/upload.pyi b/reflex/components/core/upload.pyi index f11d1ea10..5509d832e 100644 --- a/reflex/components/core/upload.pyi +++ b/reflex/components/core/upload.pyi @@ -29,11 +29,11 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: ... @CallableEventSpec def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ... def cancel_upload(upload_id: str) -> EventSpec: ... -def get_uploaded_files_dir() -> Path: ... +def get_upload_dir() -> Path: ... uploaded_files_url_prefix: Var -def get_uploaded_file_url(file_path: str) -> str: ... +def get_upload_url(file_path: str) -> str: ... class UploadFilesProvider(Component): @overload