dextuploadjk.support.common
Class JKExtensionUploadFilter
- Minimum version
- 1.0.0
- Minimum environment
- Java 17, Jakarta EE 9+
- Description
-
The JKExtensionUploadFilter class is a class that implements the javax.servlet.Filter interface and is responsible for large file upload functionality. Because it is a Filter class, it is automatically loaded by the Java servlet container (like a Tomcat server) and handles large file uploads without any code-level creation or invocation.
Here's how to set up the JKExtensionUploadFilter filter in DD(web.xml).
# web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>dextuploadjk.support.common.JKExtensionUploadFilter</filter-class> <!-- Omit configuration parameters --> </filter> <filter-mapping> <filter-name>extensionUploadFilter</filter-name> <!-- Map the servlet or URL where you want large uploads to be processed. <servlet-name>Serlvet name</servlet-name> <url-pattern>URL mapping</url-pattern> --> </filter-mapping> - Setting the parameters
-
Use the init-param element to set the parameters of the JKExtensionUploadFilter filter.
# web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>dextuploadjk.support.common.JKExtensionUploadFilter</filter-class> <init-param> <param-name>tempRepository</param-name> <param-value>/file/temp</param-value> </init-param> <init-param> <param-name>defaultRepository</param-name> <param-value>/file/store</param-value> </init-param> ... </filter> - Parameter type
-
Parameter name Default value Description tempRepository (Required) Sets the path to the temporary directory. The path must be a physical full path depending on the OS environment. If the path value does not start with a '/' or drive string, it is internally recognized as a path starting from the web application root directory.
defaultRepository (Required) Set the default directory path where files will be stored. The path must be a physical full path based on the OS environment. If the path value does not start with a '/' or drive string, it is internally recognized as a path starting from the web application root directory.
autoMakingDirectory false When saving the file, set whether to create a directory if it does not exist (true or false). If the web application does not have permission to create the directory, an error is raised.
whiteExtensions (Empty) Sets the list of file extensions that are not subject to upload restrictions. The list of file extensions is separated by the character ',' like 'jpg,gif,png,docx,...' like 'jpg,gif,png,docx,...'.
enableCleaner false When uploading large files, there may be temporary files that are left behind when the upload is not completed due to various circumstances. Setting the enableCleaner property to true will trigger a file cleaner that will internally remove temporary files at regular intervals (1 minute).
timeAgo 0 Sets the difference between the last modified time of the temporary files you want the file cleaner to remove and the current time. For example, a value of 32 will cause the file cleaner to delete all temporary files whose last modification time was more than 32 hours ago.
The hour value, which defaults to 0, but if it is less than or equal to 0, File Cleaner will set it to 24 hours.
fileCopyOption Channel When copying files internally, set how the files are copied.
Choose from Channel, Stream, ScatterGather, or MemoryMapping, but typically use Channel.
fileCopyBufferSize 32768 Set the size (in bytes) of the buffer to read/write to when copying files.
maxFileSize 0 If you want to limit the size of individual files, set the maximum allowed size (in bytes).
The default is 0, which means no limit.
maxTotalSize 0 If you want to limit the overall size of the file, set the maximum allowed size (in bytes). Large file uploads will behave as if you set individual file size limits. (no overall limit)
Defaults to 0, which means no limit.
loosely
(Not recommended)false Set to relax the level of analysis of multi-part data.
checksumEnable false Set when you want to perform integrity checks on uploaded files. Integrity checks are performed only for files that are uploaded in large file upload mode using the DEXTUploadX5 product (version 3.4.0.0 or later).
licenseFilePath (Empty) Set the server license file path. The path must be a physical full path based on your OS environment.
licenseConfigXmlPath (Empty) licenseAuthKey (Empty) Set the authentication key string if you are using a domain license or a combined license.
filterConfigLocation (Empty) Set the path to the properties file with the parameter setting values.
The path to the properties file must be the full physical path according to your OS environment. If the path value does not start with a '/' or drive string, it is internally recognized as a path starting from the web application root directory.
- Setting parameters using the properties file
-
Support for loading JKExtensionUploadFilter's parameter settings using a properties file.
# /some/path/dextuploadjk-uploadfilter-sample.properties dextuploadjk.uploadFilter.tempRepository=/file/temp dextuploadjk.uploadFilter.defaultRepository=/file/store dextuploadjk.uploadFilter.autoMakingDirectory=true dextuploadjk.uploadFilter.maxFileSize= dextuploadjk.uploadFilter.maxTotalSize= dextuploadjk.uploadFilter.whiteExtensions= dextuploadjk.uploadFilter.enableCleaner=true dextuploadjk.uploadFilter.timeAgo=24 dextuploadjk.uploadFilter.checksumEnable=false dextuploadjk.uploadFilter.licenseFilePath= # web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>dextuploadjk.support.common.JKExtensionUploadFilter</filter-class> <init-param> <param-name>filterConfigLocation</param-name> <param-value>/some/path/dextuploadjk-uploadfilter-sample.properties</param-value> </init-param> </filter>If you set the path to the properties file using the filterConfigLocation parameter, the JKExtensionUploadFilter filter will load the target properties file and read the basic settings. If you did not declare the filterConfigLocation parameter, it will look for the dextuploadjk/dextuploadjk-uploadfilter-default.properties file in the web application's classpath, and if it exists, it will load the file to retrieve the settings.
If you have created dextuploadjk-uploadfilter-default.properties and made it accessible in your web application's classpath location as dextuploadjk/dextuploadjk-uploadfilter-default.properties, this means that when you set up the JKExtensionUploadFilter filter in your web.xml, you can use it without the parameter setting part.
# web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>dextuploadjk.support.common.JKExtensionUploadFilter</filter-class> <!-- No parameterization is required. Load the settings from dextuploadjk/dextuploadjk-uploadfilter-default.properties. --> </filter>Assuming the src/main/resources location is set as the output destination at compile time, if the dextuploadjk/dextuploadjk-uploadfilter-default.properties file exists under src/main/resources in the project, it can be accessed by the path /resources/dextuploadjk-uploadfilter-default.properties in the classpath. Therefore, it is recommended to create a dextuploadjk-uploadfilter-default.properties file in src/main/resources/dextuploadjk to set the default parameters. For WAR applications, the dextuploadjk-uploadfilter-default.properties file can be found in the WEB-INF/classes/dextuploadjk directory after deployment. This is true if the src/main/resources location is specified as WEB-INF/classes in your project's packaging settings.

If you set duplicate parameters in both the properties file and web.xml, the web.xml parameter settings are prioritized.