www.dextsolution.com
DEXTUPLOAD
NJ
menu toggleReference > devpia > dextuploadnj > Environment

devpia.dextuploadnj
Class Environment

Minimum version supported
1.0.0
Minimum support environment
JRE 1.6
Description

DEXTUploadNJ provides several configuration options needed to run the file upload service.

In the JSP/Servlet environment, creating and setting the Environment object
Environment env = new Environment(); 
env.setCharEncoding("UTF-8");
env.setTempRepository("/file/temp");
env.setDefaultRepository("file/attach");
env.setAutoMakingDirectory(true);
...
// Specify the Environment object as the second parameter.
FileUpload dextnj = new FileUpload(request, env);

// Or it can be set using the setEnvironment method of the FileUpload class. 
FileUpload dextnj = new FileUpload(request);
dextnj.setEnvironment(env);
In large-file upload environment, creating and setting.

Set to the init-param of the ExtensionFileUploadFilter filter.

<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/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, creating and setting the Environment object.

The Environment object is beaned from servlet context XML in projects using the Spring Web Framework.

<bean id="environment" class="devpia.dextuploadnj.Environment">
  <property name="tempRepository" value="/file/temp"/>
  <property name="defaultRepository" value="/file/attach"/>  
  <property name="autoMakingDirectory" value="true"/>
  ...
</bean>
<bean id="multipartResolver" 
  class="devpia.dextuploadnj.support.spring.DEXTUploadNJMultipartResolver">
  <property name="environment" ref="environment"/>
</bean>
In Spring Web Framework based large file upload environment, creating and configuring Environment

Sets it to the init-param of the ExtensionFileUploadFilter filter, not DEXTUploadNJMultipartResolver.

Constructor

Environment

  • Creates an Environment class object.
  • Signatures

    public Environment()
Methods

getTempRepository

  • Returns the path of the directory containing temporary files.
  • Signatures

    public String getTempRepository()
  • Returns

    The path of the directory where temporary files are stored

setTempRepository

  • Sets the directory path where the temporary file is stored. The path must be an absolute path.

  • Signatures

    public void setTempRepository(String tempRepositoryPath)
  • Parameters

    Name Type Description
    tempRepositoryPath java.lang.String The path of temporary directory
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setTempRepository("/home/user/temp");
    
    # When set as a property of an Environment bean
    <property name="tempRepository" value="/home/user/temp"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <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 is saved.
  • Signatures

    public String getDefaultRepository()
  • Returns

    The default directory path where the file is saved

setDefaultRepository

  • Sets the default directory path where the file is saved. The path must be an absolute path.

  • Signatures

    public void setDefaultRepository(String defaultRepositoryPath)
  • Parameters

    Name Type Description
    defaultRepositoryPath java.lang.String The default directory path where the file is saved
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setDefaultRepository("/home/user/repository");
    
    # When set as a property of an Environment bean
    <property name="defaultRepository" value="/home/user/repository"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>defaultRepository</param-name>
      <param-value>/home/user/repository</param-value>
    </init-param>

getFileSeperator

  • Returns the path separator of a file or directory. The return value is the same as System.getProperty("file.separator").

  • Signatures

    public String getFileSeperator()
  • Returns

    The file or directory path separator

getMaxFileSize

  • Returns the maximum allowable size of an each file.

  • Signatures

    public long getMaxFileSize()
  • Returns

    The maximum allowable size of each file

setMaxFileSize

  • Sets the maximum allowable size of each file. If you set the size to 0, you are not checking the size of individual files.

  • Signatures

    public void setMaxFileSize(long maxFileSize)
  • Parameters

    Name Type Description
    maxFileSize long The maximum allowed size(byte) of each file
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setMaxFileSize(1024 * 1024 * 100);
    
    # When set as a property of an Environment bean
    <property name="maxFileSize" value="104857600"/>

    In large file upload environment, it supports since 2.5.0 version.

getMaxTotalSize

  • Returns the maximum allowable size of all files to be uploaded.

  • Signatures

    public long getMaxTotalSize()
  • Returns

    The maximum allowable size of the entire file to be uploaded

setMaxTotalSize

  • Sets the maximum allowable size of all files to be uploaded.

    Note) If there is a request size limit from the Web server or WAS server, the server side limit takes precedence.

  • Signatures

    public void setMaxTotalSize(long maxTotalSize)
  • Parameters

    Name Type Description
    maxTotalSize long The maximum allowable size(byte) of all files
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setMaxTotalSize(1024 * 1024 * 100);
    
    # When set as a property of an Environment bean
    <property name="maxTotalSize" value="104857600"/>

    It is not used in large file upload environment, but has the same effect as setMaxFileSize from version 2.5.0.

getAutoMakingDirectory

  • Returns whether or not to create the directory to save files.

  • Signatures

    public boolean getAutoMakingDirectory()
  • Returns

    true, false

setAutoMakingDirectory

  • Sets whether to create the directory to save files.

    Note) If the web application does not have the authority to create the directory, an error will occur.

  • Signatures

    public void setAutoMakingDirectory(boolean autoMakingDirectory)
  • Parameters

    Name Type Description
    autoMakingDirectory boolean true, false
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setAutoMakingDirectory(true);
    
    # When set as a property of an Environment bean
    <property name="autoMakingDirectory" value="true"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>autoMakingDirectory</param-name>
      <param-value>true</param-value>
    </init-param>

getCharEncoding

  • Returns the encoding character set for body interpretation.

  • Signatures

    public String getCharEncoding()
  • Returns

    The name of the encoding character set(The default value is "UTF-8".)

setCharEncoding

  • Sets the encoding character set for body interpretation.

    If the encoding of the request is different from the encoding set, special characters will crack, which can be a problem when saving the file.

  • Signatures

    public void setCharEncoding(String encodingName)
  • Parameters

    Name Type Description
    encodingName java.lang.String the name of the encoding character set
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setCharEncoding("UTF-8");
    
    # When set as a property of an Environment bean
    <property name="charEncoding" value="UTF-8"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>charEncoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>

getLicenseFilePath

  • Returns the path of the license file.

  • Signatures

    public String getLicenseFilePath()
  • Returns

    The path of the license file

setLicenseFilePath

  • Set the path of the license file. The path must be an absolute path.

  • Signatures

    public void setLicenseFilePath(String licenseFilePath)
  • Parameters

    Name Type Description
    licenseFilePath java.lang.String The path of the license file
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setLicenseFilePath("/home/user/license/dextuploadnj.config");
    
    # When set as a property of an Environment bean
    <property name="licenseFilePath" value="/home/user/license/dextuploadnj.config"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>licenseFilePath</param-name>
      <param-value>/home/user/license/dextuploadnj.config</param-value>
    </init-param>

setLicenseConfigXmlPath

  • Sets the path of the license management XML file. The path must be an absolute path.

  • Signatures

    public void setLicenseConfigXmlPath(String licenseConfigXmlPath)
  • Parameters

    Name Type Description
    licenseConfigXmlPath java.lang.String The path of the license management XML file
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setLicenseConfigXmlPath("/home/user/license/dextuploadnj-licenses.xml");
    
    # When set as a property of an Environment bean
    <property name="licenseConfigXmlPath" value="/home/user/license/dextuploadnj-licenses.xml"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>licenseConfigXmlPath</param-name>
      <param-value>/home/user/license/dextuploadnj-licenses.xml</param-value>
    </init-param>

    For details , refer to the document "Application of server License using XML".

getLicenseAuthKey (Supported since version 2.0.0)

  • Returns the authentication key string.

  • Signatures

    public String getLicenseAuthKey()
  • Returns

    The authentication key string

setLicenseAuthKey (Supported since version 2.0.0)

  • Sets the authentication key string.

  • Signatures

    public void setLicenseAuthKey(String licenseAuthKey)
  • Parameters

    Name Type Description
    licenseAuthKey java.lang.String The authentication key string
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setLicenseAuthKey("cfHzOu ... authentication key string ... rPTl1P");
    
    # When set as a property of an Environment bean
    <property name="licenseAuthKey" value="cfHzOu ... authentication key string ... rPTl1P"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>licenseAuthKey</param-name>
      <param-value>cfHzOu ... authentication key string ... rPTl1P</param-value>
    </init-param>

isCompact

  • Returns whether or not to omit empty elements in the request.

  • Signatures

    public boolean isCompact()
  • Returns

    true, false

setCompact

  • Sets whether or not to omit empty elements in the request.

    If it is set to true, empty files or files with length 0 are removed.

  • Signatures

    public void setCompact(boolean compact)
  • Parameters

    Name Type Description
    compact boolean true, false
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setCompact(true);
    
    # When set as a property of an Environment bean
    <property name="compact" value="true"/>

    It is not used in large file upload environment.

getFilterAction

  • Returns the method of handling filtered files.

  • Signatures

    public FilterAction getFilterAction()
  • Returns

    The enumeration constants of FilterAction

setFilterAction

  • Sets the method of handling filtered files.

    See FilterAction enumeration for how to handle files .

  • Signatures

    public void setFilterAction(FilterAction filterAction)
  • Parameters

    Name Type Description
    filterAction devpia.dextupoadnj.FilterAction The enumeration constants of FilterAction
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setFilterAction(FilterAction.Flushing);
    
    # When set as a property of an Environment bean
    <property name="filterAction" value="Flushing"/>

    In the large file upload environment, it is always processed as FilterAction.Error.

getWhiteExtensions

  • Returns a list of file extensions allowed to upload.

  • Signatures

    public String getWhiteExtensions()
  • Returns

    A list of allowed extensions(separated by ',')

setWhiteExtensions

  • Sets a list of file extensions to allow uploading.

    File extensions do not have ',' characters and wildcards can be used. A list of file extensions is a string separated by the ',' character.

    ex) jpg,gif,png,docx,z*

    When file extension filtering is set, files without extenion are always filtered. Wildcards are supported since version 2.7.0.

  • Signatures

    public void setWhiteExtensions(String whiteExtensions)
  • Parameters

    Name Type Description
    whiteExtensions java.lang.Spring A list of allowed extensions(separated by ',')
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setWhiteExtensions("jpg,png,gif,hwp,z??");
    
    # When set as a property of an Environment bean
    <property name="whiteExtensions" value="jpg,png,gif,hwp,z??"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <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 to upload as a String array.

  • Signatures

    public String[] getWhiteExtensionArray()
  • Returns

    A String array of allowed extensions(if there is no set value, an array of length 0 is returned.)

isEnableCleaner

  • Returns whether or not to use the cleaner to delete temporary files and meta information files.

  • Signatures

    public boolean isEnableCleaner()
  • Returns

    true, false

setEnableCleaner

  • Sets whether to use the cleaner to delete temporary file and meta information files.

  • Signatures

    public void setEnableCleaner(boolean enableCleaner)
  • Parameters

    Name Type Description
    enableCleaner boolean true, false
  • How to use

    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>enableCleaner</param-name>
      <param-value>true</param-value>
    </init-param>

    It is only used in file upload environments by using the ExtensionFileUploadFilter.

getTimeAgo

  • Returns the time required to select files to be deleted when the cleander is used.

  • Signatures

    public long getTimeAgo()
  • Returns

    hour

setTimeAgo

  • Sets the time required to select files to be deleted when the cleaner is used. Cleaner is used only for large file upload service. The timeAgo value is a hour unit of time, and all files before the time are subject to be deleted. Example) 1 hour: 1, 1 day: 24

  • Signatures

    public void setTimeAgo(long timeAgo)
  • Parameters

    Name Type Description
    timeAgo long Example) 1 hour: 1, 1 day: 24
  • How to use

    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>timeAgo</param-name>
      <param-value>24</param-value>
    </init-param>

    It is only used in file upload environments by using the ExtensionFileUploadFilter.

getSocketInputStreamReadBufferSize (Supported since version 1.1.0, deprecated)

  • Returns the size of the buffer that reads binary data from the upload stream.

  • Signatures

    public int getSocketInputStreamReadBufferSize()
  • Returns

    The size(byte) of the buffer(this default is 32 KB.)

setSocketInputStreamReadBufferSize (Supported since version 1.1.0, deprecated)

  • Sets the size of the buffer to read the binary data from the upload stream. The default is 32 KB.

  • Signatures

    public void setSocketInputStreamReadBufferSize(int socketInputStreamReadBufferSize)
  • Parameters

    Name Type Description
    socketInputStreamReadBufferSize int The size(byte) of the buffer, range: 4 KB to 4 MB
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setSocketInputStreamReadBufferSize(8162);
    
    # When set as a property of an Environment bean
    <property name="socketInputStreamReadBufferSize" value="8162"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>socketInputStreamReadBufferSize</param-name>
      <param-value>8162</param-value>
    </init-param>

getStreamReadRetryCount (Supported since version 1.1.0, ignored since version 2.5.0)

  • If the length of the data read from the upload stream is 0, reread the stream and return the number of retries.

  • Signatures

    public int getStreamReadRetryCount()
  • Returns

    Default 10 times

setStreamReadRetryCount (Supported since version 1.1.0, ignored since version 2.5.0)

  • If the length of the data read from the upload stream is 0, sets the number of retries to read again from the stream. The default is 10 times.

  • Signatures

    public void setStreamReadRetryCount(int streamReadRetryCount)
  • Parameters

    Name Type Description
    streamReadRetryCount int Example) 5, range: 3 to 20
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setStreamReadRetryCount(5);
    
    # When set as a property of an Environment bean
    <property name="streamReadRetryCount" value="5"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>streamReadRetryCount</param-name>
      <param-value>5</param-value>
    </init-param>

getFileCopyOption (Supported since version 1.1.0)

  • When a file is copied internally, it returns how to copy the file.

  • Signatures

    public FileCopyOption getFileCopyOption()
  • Returns

    The enumeration constants of FileCopyOption

setFileCopyOption (Supported since version 1.1.0)

  • When copying a file internally, sets the method to copy the file.

    In the 1.0.x version, we made a copy using the stream object, but we provide four copying methods from the 1.1.0 version.

    For the method of copying, see the FileCopyOption enumeration type.

    The default is FileCopyOption.Channel.

  • Signatures

    public void setFileCopyOption(FileCopyOption fileCopyOption)
  • Parameters

    Name Type Description
    fileCopyOption devpai.dextupload.FileCopyOption The enumeration constants of FileCopyOption
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setFileCopyOption(FileCopyOption.Stream);
    
    # When set as a property of an Environment bean
    <property name="fileCopyOption" value="Stream"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>fileCopyOption</param-name>
      <param-value>Stream</param-value>
    </init-param>

getFileCopyBufferSize (Supported since version 1.1.0)

  • When copying a file, it returns the size of the buffer to read / write.

  • Signatures

    public int getFileCopyBufferSize()
  • Returns

    Default 32 KB

setFileCopyBufferSize (Supported since version 1.1.0)

  • When copying files, sets the size of the buffer to be read/written. It is a buffer used when doing a copy operation using the "Channel, ScatterGather" method, not moving the file. The default is 32 KB.

  • Signatures

    public void setFileCopyBufferSize(int fileCopyBufferSize)
  • Parameters

    Name Type Description
    fileCopyBufferSize int The size(byte) of buffer, range: 4 KB to 4 MB
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setFileCopyBufferSize(1048576);
    
    # When set as a property of an Environment bean
    <property name="fileCopyBufferSize" value="1048576"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>fileCopyBufferSize</param-name>
      <param-value>1048576</param-value>
    </init-param>

isLoosely (Supported since version 2.5.0, not recommended)

  • Returns whether multi-part data analysis is mitigated.

    The default is false.

  • Signatures

    public boolean isLoosely()
  • Returns

    true, false

setLoosely (Supported since version 2.5.0, not recommended)

  • Sets whether the level of analyzing the multi-part data is low.

  • Signatures

    public void setLoosely(boolean loosely)
  • Parameters

    Name Type Description
    loosely boolean true, false
  • How to use

    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>loosely</param-name>
      <param-value>true</param-value>
    </init-param>

isChecksumEnable (Supported since version 2.6.0)

  • Returns whether to verify the checksum of files.

    The default is false.

  • Signatures

    public boolean isChecksumEnable()
  • Returns

    true, false

setChecksumEnable (Supported since version 2.6.0)

  • Sets whether to verify the checksum of files.

    This function is supported only in large file upload mode using DEXTUploadX5 product (version 3.4.0.0 or later).

  • Signatures

    public void setChecksumEnable(boolean enable)
  • Parameters

    Name Type Description
    enable boolean true, false
  • How to use

    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>checksumEnable</param-name>
      <param-value>true</param-value>
    </init-param>

getLimitFilenameRule (Supported since version 2.8.0)

  • Returns how validation is performed on filenames.

    The default value is NamingRules.None.

  • Signatures

    public NamingRules getLimitFilenameRule()
  • Returns

    The enumeration constants of NamingRules

setLimitFilenameRule (Supported since version 2.8.0)

  • Sets how validation is performed on filenames.

  • Signatures

    public void setLimitFilenameRule(NamingRules limitFilenameRule)
  • Parameters

    Name Type Description
    limitFilenameRule devpia.dextuploadnj.NamingRules The enumeration constants of NamingRules
  • How to use

    # When set direcly to an Environment object
    Environment env = new Environment();
    env.setLimitFilenameRule(NamingRules.Windows);
    
    # When set as a property of an Environment bean
    <property name="limitFilenameRule" value="Windows"/>
    
    # When set a parameter of the ExtensionFileUploadFilter or DEXTUploadNJSpringExtensionUploadFilter
    <init-param>
      <param-name>limitFilenameRule</param-name>
      <param-value>Windows</param-value>
    </init-param>