-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Describe the bug
The code:
@rx.event(background=True)
async def handle_upload(self, files: list[rx.UploadFile]):
async with self:
self.uploading = True
for file in files:
# Schedule reading the file as a task
upload_data = await file.read()
outfile = Path(self.uploads_folder) / file.filename
outfile.parent.mkdir(parents=True, exist_ok=True)
with outfile.open("wb") as file_object:
file_object.write(upload_data)
# Do some preprocessing (removed)
async with self:
self.uploading = FalseAlong with:
rx.upload(
rx.cond(
State.uploading,
rx.spinner(),
rx.button(
rx.icon(tag="upload", size=19),
class_name="bg-accent-9 hover:bg-accent-10 p-1.5 rounded-full transition-colors cursor-pointer",
),
),
id="file_upload",
class_name="flex items-center",
on_drop=State.handle_upload(rx.upload_files(upload_id="file_upload")),
style={
"padding": "0 !important",
"border": "none",
}, # Ensure no extra margin
),Results in the error:
raise UploadTypeError(
reflex.utils.exceptions.UploadTypeError: @rx.event(background=True) is not supported for upload handler `reflex___state____state.frontend___state____state.handle_upload`.
To Reproduce
Copy-paste the examples above
Expected behavior
Should work as indicated in the docs here https://reflex.dev/docs/events/background-events/. The page for uploading provides a method to track upload progress but here I am looking for uploading + preprocessing progress (just a boolean to now if its still going on).
Specifics (please complete the following information):
- Python Version: 0.6.8
- Reflex Version: 3.10
- OS: Mac OS
- Browser (Optional): Edge
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels