dextuploadjk.engine
Class Environment
- Minimum version
- 1.0.0
- Minimum environment
- Java 17, Jakarta EE 9+
- Description
-
DEXTUploadJK provides several configuration options necessary to perform file upload services.
- In a pure JSP/Servlet environment, environment creation and configuration
-
Environment env = new Environment(); env.setCharEncoding("UTF-8"); env.setTempRepository("/file/temp"); env.setDefaultRepository("file/attach"); env.setAutoMakingDirectory(true); ... // Set the Environment object using the second parameter. FileUpload dextnj = new FileUpload(request, env); // Alternatively, you can set it using the setEnvironment method of the FileUpload class. FileUpload dextnj = new FileUpload(request); dextnj.setEnvironment(env); - Creating and setting up an environment in a large file upload environment
-
Set as init-param of JKExtensionUploadFilter filter.
<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/attach</param-value> </init-param> <init-param> <param-name>autoMakingDirectory</param-name> <param-value>true</param-value> </init-param> ... </filter> - In the Spring Web Framework environment, environment creation and configuration
-
The Environment object is set in the servlet context XML in projects that use the Spring Web Framework.
<bean id="environment" class="dextuploadjk.engine.Environment"> <property name="tempRepository" value="/file/temp"/> <property name="defaultRepository" value="/file/attach"/> <property name="autoMakingDirectory" value="true"/> ... </bean> <bean id="multipartResolver" class="dextuploadjk.support.spring.JKMultipartResolver"> <property name="environment" ref="environment"/> </bean> - Creating and setting up an environment in a large file upload environment based on the Spring Web Framework
-
Set as init-param of the JKExtensionUploadFilter filter, not JKMultipartResolver.
- Constructor
-
Environment
- Creates an object of the Environment class.
-
Signatures
public Environment()
- Methods
-
getTempRepository
- Returns the directory path where temporary files are stored.
-
Signatures
public String getTempRepository()
-
Return
Directory path where temporary files are stored
setTempRepository
-
Set the directory path where temporary files are stored. The directory path must be an absolute path.
-
Signatures
public void setTempRepository(String tempRepositoryPath)
-
Parameters
Name Type Description tempRepositoryPath java.lang.String Temporary directory path -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setTempRepository("/home/user/temp"); # When setting in Spring's DispatcherServlet context XML <property name="tempRepository" value="/home/user/temp"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>tempRepository</param-name> <param-value>/home/user/temp</param-value> </init-param>
getDefaultRepository
- Returns the default directory path where the file will be saved.
-
Signatures
public String getDefaultRepository()
-
Return
Base directory path where files will be saved
setDefaultRepository
-
Set the default directory path where files will be saved. Directory paths must be absolute.
-
Signatures
public void setDefaultRepository(String defaultRepositoryPath)
-
Parameters
Name Type Description defaultRepositoryPath java.lang.String Base directory path where files will be saved -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setDefaultRepository("/home/user/repository"); # When setting in Spring's DispatcherServlet context XML <property name="defaultRepository" value="/home/user/repository"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>defaultRepository</param-name> <param-value>/home/user/repository</param-value> </init-param>
getFileSeperator
-
Returns the file or directory path separator.
The return value is the same as System.getProperty("file.separator").
-
Signatures
public String getFileSeperator()
-
Return
File or directory path separator
getMaxFileSize
-
Returns the maximum allowable size of an individual file.
-
Signatures
public long getMaxFileSize()
-
Return
Maximum allowable size of individual files
setMaxFileSize
-
Set the maximum allowable size of individual files.
-
Signatures
public void setMaxFileSize(long maxFileSize)
-
Parameters
Name Type Description maxFileSize long Maximum allowable size of individual files(in bytes) -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setMaxFileSize(1024 * 1024 * 100); # When setting in Spring's DispatcherServlet context XML <property name="maxFileSize" value="104857600"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>maxFileSize</param-name> <param-value>104857600</param-value> </init-param>
getMaxTotalSize
-
Returns the maximum allowable size of all files to be uploaded.
-
Signatures
public long getMaxTotalSize()
-
Return
Maximum allowable size of total files to upload
setMaxTotalSize
-
Set the maximum allowable size of all files to be uploaded.
If size is set to 0, individual file sizes are not checked.
Note) If there is a request size limit on the web server or WAS server, the server-side limit takes priority.
-
Signatures
public void setMaxTotalSize(long maxTotalSize)
-
Parameters
Name Type Description maxTotalSize long Maximum allowed size of entire file (in bytes) -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setMaxTotalSize(1024 * 1024 * 100); # When setting in Spring's DispatcherServlet context XML <property name="maxTotalSize" value="104857600"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>maxTotalSize</param-name> <param-value>104857600</param-value> </init-param>
It is not used in Extnesion file-upload environment, but has the same effect as setMaxFileSize.
getAutoMakingDirectory
-
When saving a file, if the parent directory does not exist, returns whether to create a directory.
-
Signatures
public boolean getAutoMakingDirectory()
-
Return
Whether to create a directory
setAutoMakingDirectory
-
When saving a file, sets whether to create a directory if the parent directory does not exist.
Note) If the web application does not have permission to create a directory, an error occurs.
-
Signatures
public void setAutoMakingDirectory(boolean autoMakingDirectory)
-
Parameters
Name Type Description autoMakingDirectory boolean true if automatically generated, false otherwise. -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setAutoMakingDirectory(true); # When setting in Spring's DispatcherServlet context XML <property name="autoMakingDirectory" value="true"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>autoMakingDirectory</param-name> <param-value>true</param-value> </init-param>
getCharEncoding
-
Returns the encoding character set for text interpretation.
-
Signatures
public String getCharEncoding()
-
Return
Encoding character set. The default is UTF-8.
setCharEncoding
-
Set the encoding character set for text interpretation.
If the requested encoding is different from the set encoding, special characters or Korean characters may be broken, which can cause problems when saving the file.
-
Signatures
public void setCharEncoding(String encodingName)
-
Parameters
Name Type Description encodingName java.lang.String Encoding character set name -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setCharEncoding("UTF-8"); # When setting in Spring's DispatcherServlet context XML <property name="charEncoding" value="UTF-8"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>charEncoding</param-name> <param-value>UTF-8</param-value> </init-param>
getLicenseFilePath
-
Returns the license file path.
-
Signatures
public String getLicenseFilePath()
-
Return
License file path
setLicenseFilePath
-
Set the license file path. The license file path must be an absolute path.
-
Signatures
public void setLicenseFilePath(String licenseFilePath)
-
Parameters
Name Type Description licenseFilePath java.lang.String License file path -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setLicenseFilePath("/home/user/license/dextuploadjk.config"); # When setting in Spring's DispatcherServlet context XML <property name="licenseFilePath" value="/home/user/license/dextuploadjk.config"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>licenseFilePath</param-name> <param-value>/home/user/license/dextuploadjk.config</param-value> </init-param>
setLicenseConfigXmlPath
-
Set the license management XML file path. The license management XML file path must be an absolute path.
-
Signatures
public void setLicenseConfigXmlPath(String licenseConfigXmlPath)
-
Parameters
Name Type Description licenseConfigXmlPath java.lang.String License management XML file path -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setLicenseConfigXmlPath("/home/user/license/dextuploadjk-licenses.xml"); # When setting in Spring's DispatcherServlet context XML <property name="licenseConfigXmlPath" value="/home/user/license/dextuploadjk-licenses.xml"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>licenseConfigXmlPath</param-name> <param-value>/home/user/license/dextuploadjk-licenses.xml</param-value> </init-param>For more details, refer to the 'Applying the server license using XML' document.
getLicenseAuthKey
-
Returns the authentication key string.
-
Signatures
public String getLicenseAuthKey()
-
Return
Authentication key string
setLicenseAuthKey
-
Set the authentication key string.
-
Signatures
public void setLicenseAuthKey(String licenseAuthKey)
-
Parameters
Name Type Description licenseAuthKey java.lang.String Authentication key string -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setLicenseAuthKey("cfHzOu ...... rPTl1P"); # When setting in Spring's DispatcherServlet context XML <property name="licenseAuthKey" value="cfHzOu ...... rPTl1P"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>licenseAuthKey</param-name> <param-value>cfHzOu ...... rPTl1P</param-value> </init-param>
isCompact
-
Returns whether the request is abbreviated.
-
Signatures
public boolean isCompact()
-
Return
true, false
setCompact
-
Set whether to abbreviate the request.
If set to true, empty file entries or zero-length file entries are removed.
-
Signatures
public void setCompact(boolean compact)
-
Parameters
Name Type Description compact boolean true, false -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setCompact(true); # When setting in Spring's DispatcherServlet context XML <property name="compact" value="true"/>
It is not used in Extension file-upload environment.
getFilterAction
-
Returns the processing method for restricted files.
-
Signatures
public FilterAction getFilterAction()
-
Return
FilterAction enumeration value
setFilterAction
-
Set processing methods for restricted files.
For information on how to process files, refer to the FilterAction enumeration.
-
Signatures
public void setFilterAction(FilterAction filterAction)
-
Parameters
Name Type Description filterAction devpia.dextupoadnj.FilterAction FilterAction enumeration value -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setFilterAction(FilterAction.Flushing); # When setting in Spring's DispatcherServlet context XML <property name="filterAction" value="Flushing"/>
In a large file upload environment, it is always handled as FilterAction.Error.
getWhiteExtensions
-
Returns a list of file extensions allowed for upload.
-
Signatures
public String getWhiteExtensions()
-
Return
List of allowed extensions (separated by ',') string
setWhiteExtensions
-
Set a list of file extensions allowed for upload.
The file extension is a substring excluding '.' and can include wildcards as needed. The file extension list is separated by the ',' character.
ex) jpg,gif,png,docx,z*
-
Signatures
public void setWhiteExtensions(String whiteExtensions)
-
Parameters
Name Type Description whiteExtensions java.lang.Spring List of allowed extensions (separated by ',') string -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setWhiteExtensions("jpg,png,gif,hwp,z??"); # When setting in Spring's DispatcherServlet context XML <property name="whiteExtensions" value="jpg,png,gif,hwp,z??"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>whiteExtensions</param-name> <param-value>jpg,png,gif,hwp,z??</param-value> </init-param>
getWhiteExtensionArray
-
Returns a list of file extensions allowed for upload as an array.
-
Signatures
public String[] getWhiteExtensionArray()
-
Return
Array of list of allowed extensions. If no value is set, an array with length 0 is returned.
isEnableCleaner
-
Returns whether to use a cleaner to delete temporary files and meta information files.
-
Signatures
public boolean isEnableCleaner()
-
Return
true, false
setEnableCleaner
-
Set whether to use a cleaner to delete temporary files and meta information files.
-
Signatures
public void setEnableCleaner(boolean enableCleaner)
-
Parameters
Name Type Description enableCleaner boolean true, false -
Uses
# When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>enableCleaner</param-name> <param-value>true</param-value> </init-param>
Used only in file upload environments that use JKExtensionUploadFilter or JKSpringExtensionUploadFilter.
getTimeAgo
-
When the cleaner is used, it returns the reference time required to select the target file to be deleted.
-
Signatures
public long getTimeAgo()
-
Return
Time unit value
setTimeAgo
-
When the cleaner is used, it sets a standard time for selecting target files to be deleted.
Cleaner is only used in large file upload services.
The timeAgo value is in units of time, and all files a unit of time before the current time are subject to deletion. Example) 1 hour: 1, day: 24
-
Signatures
public void setTimeAgo(long timeAgo)
-
Parameters
Name Type Description timeAgo long Example) 1 hour: 1, day: 24 -
Uses
# When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>timeAgo</param-name> <param-value>24</param-value> </init-param>
Used only in file upload environments that use JKExtensionUploadFilter or JKSpringExtensionUploadFilter.
getFileCopyOption
-
When copying a file internally, returns the method of copying the file.
-
Signatures
public FileCopyOption getFileCopyOption()
-
Return
Default FileCopyOption.Channel
setFileCopyOption
-
When copying files internally, set the method for copying files.
For copy methods, refer to the FileCopyOption enumeration.
The default is FileCopyOption.Channel.
-
Signatures
public void setFileCopyOption(FileCopyOption fileCopyOption)
-
Parameters
Name Type Description fileCopyOption dextuplodjk.engine.FileCopyOption An enumeration object representing how to copy a file. -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setFileCopyOption(FileCopyOption.Stream); # When setting in Spring's DispatcherServlet context XML <property name="fileCopyOption" value="Stream"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>fileCopyOption</param-name> <param-value>Stream</param-value> </init-param>
getFileCopyBufferSize
-
When copying a file, returns the size of the buffer to read/write.
-
Signatures
public int getFileCopyBufferSize()
-
Return
Default 32KB
setFileCopyBufferSize
-
When copying a file, set the size of the buffer to read/write.
This is a buffer used when copying files using the 'Channel, ScatterGather' method, rather than moving files.
The default is 32KB.
-
Signatures
public void setFileCopyBufferSize(int fileCopyBufferSize)
-
Parameters
Name Type Description fileCopyBufferSize int Size of buffer in bytes (8162), range: 4KB to 4MB -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setFileCopyBufferSize(1048576); # When setting in Spring's DispatcherServlet context XML <property name="fileCopyBufferSize" value="1048576"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>fileCopyBufferSize</param-name> <param-value>1048576</param-value> </init-param>
isLoosely (not recommended)
-
Returns whether to ease multi-part data analysis.
The default is false.
-
Signatures
public boolean isLoosely()
-
Return
true, false
setLoosely (not recommended)
-
Set whether to relax multi-part data analysis.
-
Signatures
public void setLoosely(boolean loosely)
-
Parameters
Name Type Description loosely boolean true, false -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setLoosely(true); # When setting in Spring's DispatcherServlet context XML <property name="loosley" value="true"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>loosley</param-name> <param-value>true</param-value> </init-param>
isChecksumEnable
-
Returns whether the integrity of the uploaded file is checked.
The default is false.
-
Signatures
public boolean isChecksumEnable()
-
Return
true, false
setChecksumEnable
-
Set whether to check the integrity of uploaded files.
This feature is only supported in large file upload mode using the DEXTUploadX5 product (version 3.4.0.0 or higher).
-
Signatures
public void setChecksumEnable(boolean enable)
-
Parameters
Name Type Description enable boolean true, false -
Uses
# When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>checksumEnable</param-name> <param-value>true</param-value> </init-param>
getLimitFilenameRule
-
Returns the method for performing validation on file names.
The default is NamingRules.None.
-
Signatures
public NamingRules getLimitFilenameRule()
-
Return
A NamingRules enumeration value
setLimitFilenameRule
-
Set the method of performing validation for file names.
-
Signatures
public void setLimitFilenameRule(NamingRules limitFilenameRule)
-
Parameters
Name Type Description limitFilenameRule dextuploadjk.NamingRules A NamingRules enumeration value -
Uses
# When setting directly to the Environment object Environment env = new Environment(); env.setLimitFilenameRule(NamingRules.Windows); # When setting in Spring's DispatcherServlet context XML <property name="limitFilenameRule" value="Windows"/> # When set with the JKExtensionUploadFilter or JKSpringExtensionUploadFilter parameter <init-param> <param-name>limitFilenameRule</param-name> <param-value>Windows</param-value> </init-param>