ui.upload frontend component #3862
Replies: 1 comment 2 replies
-
After further testing this, I would like to ask for a best practice advice on how to deal with session cuts in case the selection of the file is taking too long and the session is cut. With my component: I click on the icon and the file browser opens. If it takes too long I see in the logs and after I return from the filebrowser this: the next client connect is from a different id and the old id is never connecting again. The page knows the state of the fields, so that is not an issue. Its specifically about how to handle uploads. Any advice would be highly appreciated BR/Peter |
Beta Was this translation helpful? Give feedback.
-
Hi guys,
recently I am trying to develop own components for my project. I wanted to have a simpler and smaller ui.upload panel. Basically it should just be a button with a counter. It should allow to upload several files by clicking it more than once and it should allow to save data into memory for further processing before saving to disk. Also, I just wanted to have ONE uploader in my project, so with this component I can still choose to show the original ui.upload or my button solution.
This is my code so far:
And it is used as easy as
where
self.after_upload_attachment
is my callback to process the upload. You can easily modify all used niceGUI components like the badge, button or the original upload panel (like in this example I set the badge text).It shows up like this (screenshot from my app):
![Screenshot_20241011_090052_Chrome](https://private-user-images.githubusercontent.com/59268713/375656471-7055f749-f548-449d-9c3c-a783beaa6559.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTIwMTcsIm5iZiI6MTczOTY5MTcxNywicGF0aCI6Ii81OTI2ODcxMy8zNzU2NTY0NzEtNzA1NWY3NDktZjU0OC00NDlkLTljM2MtYTc4M2JlYWE2NTU5LmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA3NDE1N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEzM2M4MzM4NjUyYmM1Yjg1YWM2Zjc4ZjQ0OTkzMjY5ZDkyNWYzMDgxNzA2ZTdkODY3ZDUwNDhhZjZiNWQxZmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._h37XP8vAP-ftPJICUtt7A0zwaSwe8qA6oRB4OU5_RU)
On mobile devices (tested on Android) it will allow the user to pick either the camera app or voice recorder app or file picker to provide the data. On Windows it will start the file picker.
BR/Peter
Beta Was this translation helpful? Give feedback.
All reactions