[REF-2157] Allow rx.download
to resolve rx.get_upload_url
links (#2813)
This commit is contained in:
parent
4413cb4038
commit
94e750a5f1
@ -161,7 +161,8 @@ export const applyEvent = async (event, socket) => {
|
||||
if (event.name == "_download") {
|
||||
const a = document.createElement("a");
|
||||
a.hidden = true;
|
||||
a.href = event.payload.url;
|
||||
// Special case when linking to uploaded files
|
||||
a.href = event.payload.url.replace("${getBackendURL(env.UPLOAD)}", getBackendURL(env.UPLOAD))
|
||||
a.download = event.payload.filename;
|
||||
a.click();
|
||||
a.remove();
|
||||
|
@ -128,7 +128,7 @@ uploaded_files_url_prefix: Var = Var.create_safe(
|
||||
)
|
||||
|
||||
|
||||
def get_upload_url(file_path: str) -> str:
|
||||
def get_upload_url(file_path: str) -> Var[str]:
|
||||
"""Get the URL of an uploaded file.
|
||||
|
||||
Args:
|
||||
@ -139,7 +139,7 @@ def get_upload_url(file_path: str) -> str:
|
||||
"""
|
||||
Upload.is_used = True
|
||||
|
||||
return f"{uploaded_files_url_prefix}/{file_path}"
|
||||
return Var.create_safe(f"{uploaded_files_url_prefix}/{file_path}")
|
||||
|
||||
|
||||
def _on_drop_spec(files: Var):
|
||||
|
@ -40,7 +40,7 @@ def get_upload_dir() -> Path: ...
|
||||
|
||||
uploaded_files_url_prefix: Var
|
||||
|
||||
def get_upload_url(file_path: str) -> str: ...
|
||||
def get_upload_url(file_path: str) -> Var[str]: ...
|
||||
|
||||
class UploadFilesProvider(Component):
|
||||
@overload
|
||||
|
Loading…
Reference in New Issue
Block a user