minor
#24715
Dealing with large file sizes during uploads through file drops
Currently, neither the FileDropHandler nor the GalleryControl checks the number or size of files to be uploaded. This may result in overhead, and the upload may not complete correctly. Therefore, it should be possible to set a limit on the maximum upload size.
Improvement
The `max-upload-size` can now be configured in both the WebFolderComponent and the WebFolderUIFactory. The size is specified using the `MemorySizeFormat`. If the WebFolderComponent does not have a corresponding configuration, it uses that of the WebFolderUIFactory, which is set to “unlimited” by default. \\ To enable unlimited uploads, enter 0. The GalleryControl already has a configuration for maximum uploads (MAX_DATABASE_SIZE_MEGABYTE in the ImageSizeConfig) and now uses this setting for file-drop uploads as well. \\ In addition, a check is already performed on the client side to determine whether the maximum size has been exceeded. If an error occurs, it is sent back to the server as a message containing the maximum upload size, allowing the server to generate an appropriate error message.
Usage
The WebFolderUIFactory and the WebFolderComponent are configured as follows: {{{#!xml <config service-class="com.top_logic.common.webfolder.ui.WebFolderUIFactory">
<instance max-upload-size="0" />
</config> }}}
{{{#!xml <config config:interface="com.top_logic.common.webfolder.ui.WebFolderComponent$Config
"max-upload-size="1024"
/> }}}
Test
In WebFolder, under Structures > A > Type Demo, start an upload via drag-and-drop. If the upload size exceeds 5 MB, an error message must appear and nothing should be uploaded. The same applies to the WebFolder under Structures > A > Documents and GalleryControl.
Code Migration
- FileDropHandler now also implements the getMaxUploadSize function
- The FolderFileDropHandler constructor now also accepts a ` maxSize ` parameter for the maximum size of data that can be uploaded:
FolderFileDropHandler(boolean manualLocking, boolean uploadPossible, long maxSize)