devpia.dextuploadnj.support.common
Class ExtensionFileUploadFilter
- Minimum version supported
- 1.0.0
- Minimum support environment
- JRE 1.6
- Description
-
The ExtensionFileUploadFilter 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 ExtensionFileUploadFilter filter in your DD(web.xml).
# web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>devpia.dextuploadnj.support.common.ExtensionFileUploadFilter</filter-class> <!-- omit setting parameters --> </filter> <filter-mapping> <filter-name>extensionUploadFilter</filter-name> <!-- Map the servlet or URL where you want large uploads to be processed. <servlet-name>Servlet name</servlet-name> <url-pattern>Mapping URL</url-pattern> --> </filter-mapping> - Setting parameters
-
Use the init-param element to set the parameters of the ExtensionFileUploadFilter filter.
# web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>devpia.dextuploadnj.support.common.ExtensionFileUploadFilter</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 Types
-
Parameter Name Default Description tempRepository (Required) Sets the path to the temporary directory. 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 with the web application root directory.
defaultRepository (Required) Sets 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 will be recognized internally as a path starting from the web application root directory.
autoMakingDirectory false Sets whether a directory should be created (true or false) when saving a file if it doesn't already exist. If the web application does not have permission to create the directory, an error will be thrown.
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,...'.
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. If you set the enableCleaner property to true, a file cleaner will be run internally to remove temporary files at regular intervals (1 minute).
timeAgo 0 Sets the difference between the last modified time of the temporary files the file cleaner wants 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 was more than 32 hours ago.
The value of hour, which defaults to 0, but if it is less than or equal to 0, File Cleaner will set it to 24 hours.
socketInputStreamReadBufferSize
(supported since version 1.1.0, not recommended)32768 Sets the size (in bytes) of the buffer for reading binary data from the upload stream.
streamReadRetryCount
(supported since version 1.1.0, deprecated since version 2.5.0)10 Sets the number of retries to read the stream again if the length of the data read from the upload stream is zero.
fileCopyOption
(supported since version 1.1.0)Channel Sets the method for copying files when file copying is done internally.
Choose from Channel, Stream, ScatterGather, or MemoryMapping, but typically use Channel.
fileCopyBufferSize
(supported since version 1.1.0)32768 Sets the size (in bytes) of the buffer to read/write to when copying a file.
maxFileSize
(Supported since version 2.5.0)0 Sets the maximum allowed size (in bytes) for individual files when you want to limit the size of each file.
The default value is 0, which means no limit.
maxTotalSize
(supported since version 2.5.0)0 Set the maximum allowed size (in bytes) when you want to limit the overall size of the file. Large file uploads will behave as if individual file size limits were set. (No overall limit)
Defaults to 0, which means no limit.
loosely
(supported since version 2.5.0, not recommended)false Set to relax the level of analysis of multi-part data.
checksumEnable
(supported since version 2.6.0)false Set if you want to perform integrity checks on uploaded files. Integrity checking is only performed for files that are uploaded in large file upload mode using the DEXTUploadX5 product (version 3.4.0.0 or later).
licenseFilePath (empty) Sets the server license file path. The path must be a physical full path according to the OS environment.
licenseConfigXmlPath (empty) licenseAuthKey (empty) Set the authentication key string if you are using a domain license or a combined license.
filterConfigLocation
(supported since version 2.11.0)(empty) Sets 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 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.
- Setting parameters using a properties file (supported since version 2.11.0)
-
Starting in version 2.11.0, we support loading parameter settings for ExtensionFileUploaderFilter using a properties file.
# /some/path/dextuploadnj-uploadfilter-sample.properties dextuploadnj.uploadFilter.tempRepository=/file/temp dextuploadnj.uploadFilter.defaultRepository=/file/store dextuploadnj.uploadFilter.autoMakingDirectory=true dextuploadnj.uploadFilter.maxFileSize= dextuploadnj.uploadFilter.maxTotalSize= dextuploadnj.uploadFilter.whiteExtensions= dextuploadnj.uploadFilter.enableCleaner=true dextuploadnj.uploadFilter.timeAgo=24 dextuploadnj.uploadFilter.checksumEnable=false dextuploadnj.uploadFilter.licenseFilePath= # web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>devpia.dextuploadnj.support.common.ExtensionFileUploadFilter</filter-class> <init-param> <param-name>filterConfigLocation</param-name> <param-value>/some/path/dextuploadnj-uploadfilter-sample.properties</param-value> </init-param> </filter>If you set the path to the properties file using the filterConfigLocation parameter, the ExtensionFileUploaderFilter filter loads the target properties file and reads the default settings. If you did not declare the filterConfigLocation parameter, it looks for the dextuploadnj/dextuploadnj-uploadfilter-default.properties file in the web application's classpath, and if it exists, it loads the file to get the settings.
If you have created dextuploadnj-uploadfilter-default.properties and made it accessible in your web application's classpath location as dextuploadnj/dextuploadnj-uploadfilter-default.properties, you can use it without setting any parameters when setting the ExtensionFileUploaderFilter filter in your web.xml.
# web.xml <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>devpia.dextuploadnj.support.common.ExtensionFileUploadFilter</filter-class> <!-- No parameterization is required. Load settings from dextuploadnj/dextuploadnj-uploadfilter-default.properties. --> </filter>Assuming the src/main/resources location is set as the output destination at build time, if the dextuploadnj/dextuploadnj-uploadfilter-default.properties file exists under src/main/resources in the project, it can be accessed by the path /resources/dextuploadnj-uploadfilter-default.properties in the classpath. Therefore, it is recommended to create a dextuploadnj-uploadfilter-default.properties file in src/main/resources/dextuploadnj to set the default parameters. For WAR applications, the dextuploadnj-uploadfilter-default.properties file can be found in the WEB-INF/classes/dextuploadnj directory after deployment. This is true only if the src/main/resources location is specified as WEB-INF/classes in the project's packaging settings.

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