From 2e67ccb9abe086736053c84ae2045ddf53230330 Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Tue, 14 Oct 2025 09:54:52 +0200 Subject: [PATCH 1/3] add documentation for upload event arguments --- .../content/upload_documentation.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/website/documentation/content/upload_documentation.py b/website/documentation/content/upload_documentation.py index e9a3fbf568..294c517a53 100644 --- a/website/documentation/content/upload_documentation.py +++ b/website/documentation/content/upload_documentation.py @@ -8,6 +8,24 @@ def main_demo() -> None: ui.upload(on_upload=lambda e: ui.notify(f'Uploaded {e.file.name}')).classes('max-w-full') +doc.text('Upload event arguments', ''' + The `UploadEventArguments` class is used to pass the uploaded file to the handler. + It contains a single field `file` of type `ui.upload.FileUpload`, which contains properties + + - `name: str` and + - `content_type: str` + + as well as methods for accessing the content: + + - `read()` - read the file contents as bytes, + - `text()` - read the file contents as text, + - `json()` - read the file contents as JSON dictionary, + - `iterate()` - iterate over the file contents as bytes, + - `save()` - save the file contents to a path, + - `size()` - get the file size in bytes. +''') + + @doc.demo('Upload restrictions', ''' In this demo, the upload is restricted to a maximum file size of 1 MB. When a file is rejected, a notification is shown. From 52bed744337f5f9741a2489b4caf23d8e57a30e9 Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Tue, 14 Oct 2025 09:58:35 +0200 Subject: [PATCH 2/3] add version information --- website/documentation/content/upload_documentation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/documentation/content/upload_documentation.py b/website/documentation/content/upload_documentation.py index 294c517a53..5973a6d8d0 100644 --- a/website/documentation/content/upload_documentation.py +++ b/website/documentation/content/upload_documentation.py @@ -23,6 +23,8 @@ def main_demo() -> None: - `iterate()` - iterate over the file contents as bytes, - `save()` - save the file contents to a path, - `size()` - get the file size in bytes. + + *Added in NiceGUI 3.0.0* ''') From 67b2e54e3aca986232128ae603a5c49a2d1892de Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Wed, 15 Oct 2025 13:17:48 +0200 Subject: [PATCH 3/3] add reference for `ui.upload.FileUpload` --- website/documentation/content/upload_documentation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/documentation/content/upload_documentation.py b/website/documentation/content/upload_documentation.py index 5973a6d8d0..2f8f0de6b0 100644 --- a/website/documentation/content/upload_documentation.py +++ b/website/documentation/content/upload_documentation.py @@ -73,4 +73,5 @@ def uploading_large_files() -> None: ui.upload(on_upload=lambda e: ui.notify(f'Uploaded {e.file.name}')).classes('max-w-full') -doc.reference(ui.upload) +doc.reference(ui.upload, title='Reference for ui.upload') +doc.reference(ui.upload.FileUpload, title='Reference for ui.upload.FileUpload')