-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add download event #1797
add download event #1797
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little unclear on why this would be preferred over just using a standard link. This seems like more moving parts and harder to deal with error handling.
If I wanted to provide a download link, I would keep the href in a state Var and render a normal <a>
tag in the frontend.
This only work if the file is already available beforehand. Take an example where you have a data_table and an export button. |
Fair enough, but is it possible make the hidden |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code works well for me! Just one suggestion
reflex/event.py
Outdated
@@ -330,6 +330,29 @@ def set_clipboard(content: str) -> EventSpec: | |||
) | |||
|
|||
|
|||
def download(url: str, filename: str) -> EventSpec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they don't provide a filename, maybe we can default to the last part of the path in the url? Basically give it the same filename it was saved as
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure we could do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, great work
@@ -330,6 +330,34 @@ def set_clipboard(content: str) -> EventSpec: | |||
) | |||
|
|||
|
|||
def download(url: str, filename: Optional[str] = None) -> EventSpec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Instead of Optional
we can do str | None
now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry didn't re-review, but the merged implementation is killer, thanks for making the changes @Lendemor
All Submissions:
Type of change
New Feature Submission:
Description
Add an API for easily downloading files.
Usage is as follow:
or