Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion website/documentation/content/upload_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ 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.

*Added in NiceGUI 3.0.0*
''')


@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.
Expand Down Expand Up @@ -53,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')
Loading