clean up PR
This commit is contained in:
parent
5b283baef4
commit
60798ed1a1
@ -166,6 +166,9 @@ export const applyEvent = async (event, socket) => {
|
||||
"${getBackendURL(env.UPLOAD)}",
|
||||
getBackendURL(env.UPLOAD)
|
||||
);
|
||||
if (event.payload.filename) {
|
||||
a.href = a.href + "?filename=" + event.payload.filename;
|
||||
}
|
||||
a.download = event.payload.filename;
|
||||
a.click();
|
||||
a.remove();
|
||||
|
@ -271,12 +271,12 @@ class App(Base):
|
||||
self.api.get(str(constants.Endpoint.PING))(ping)
|
||||
|
||||
def add_optional_endpoints(self):
|
||||
"""Add optional api endpoints (_upload and _download)."""
|
||||
"""Add optional api endpoints (_upload)."""
|
||||
# To upload files.
|
||||
if Upload.is_used:
|
||||
self.api.post(str(constants.Endpoint.UPLOAD))(upload(self))
|
||||
|
||||
# To access uploaded files as assets.
|
||||
# To access uploaded files.
|
||||
self.api.mount(
|
||||
str(constants.Endpoint.UPLOAD),
|
||||
UploadedFiles(directory=get_upload_dir()),
|
||||
|
@ -129,19 +129,20 @@ uploaded_files_url_prefix: Var = Var.create_safe(
|
||||
)
|
||||
|
||||
|
||||
def get_upload_url(file_path: str, download: bool = False) -> Var[str]:
|
||||
def get_upload_url(file_path: str) -> Var[str]:
|
||||
"""Get the URL of an uploaded file.
|
||||
|
||||
Args:
|
||||
file_path: The path of the uploaded file.
|
||||
download: Whether to get the download URL instead of the upload URL.
|
||||
|
||||
Returns:
|
||||
The URL of the uploaded file to be rendered from the frontend (as a str-encoded Var).
|
||||
"""
|
||||
Upload.is_used = True
|
||||
|
||||
return Var.create_safe(f"{uploaded_files_url_prefix}/{file_path}")
|
||||
return Var.create_safe(
|
||||
f"{uploaded_files_url_prefix}/{file_path}", _var_is_string=True
|
||||
)
|
||||
|
||||
|
||||
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, download: bool = False) -> Var[str]: ...
|
||||
def get_upload_url(file_path: str) -> Var[str]: ...
|
||||
|
||||
class UploadFilesProvider(Component):
|
||||
@overload
|
||||
|
@ -10,7 +10,6 @@ class Endpoint(Enum):
|
||||
PING = "ping"
|
||||
EVENT = "_event"
|
||||
UPLOAD = "_upload"
|
||||
DOWNLOAD = "_download"
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Get the string representation of the endpoint.
|
||||
|
Loading…
Reference in New Issue
Block a user