devpia.dextuploadnj
Class FileSaveOption
- Minimum version supported
- 2.7.0
- Minimum support environment
- JRE 1.6
- Description
-
This is a class that sets options necessary for saving temporary files.
When saving temporary files using the existing FileItem.save/saveAs overloading method, it is recommended to use FileSaveOption rather than individually setting parameters. All options added after version 2.7.0 will be set only through FileSaveOption. For example, in the case of an option such as nfc, it can be set only by using FileSaveOption.
// The old way item.saveAs("/home/user/others/", "uploaded_file.txt"); // Using FileSaveOption FileSaveOption option = new FileSaveOption(); option.setTargetDirectoryPath("/home/user/others/"); option.setTargetFilename("uploaded_file.txt"); item.save(option); - Constructor
-
FileSaveOption
- Creates an instance of the FileSaveOption class.
-
Signatures
public FileSaveOption() public FileSaveOption(String targetDirectoryPath, String targetFilename, boolean overwrite, boolean copy, boolean nfc)
-
Parameters
Name Type Description targetDirectoryPath java.lang.String Directory path to save the file targetFilename java.lang.String File name to use when temporary file is saved overwrite boolean Whether to overwrite duplicate files copy boolean Whether to remove temporary files nfc boolean Whether to change to Unicode normalization form
- Methods
-
getTargetDirectoryPath
- Returns the directory path to save the file.
-
Signatures
public String getTargetDirectoryPath()
-
Returns
Directory path
setTargetDirectoryPath
-
Sets the directory path to save the file
-
Signatures
public void setTargetDirectoryPath(String targetDirectoryPath)
-
Parameters
Name Type Description targetDirectoryPath java.lang.String Directory path -
How to use
FileSaveOption option = new FileSaveOption(); option.setTargetDirectoryPath("/home/user/others/");
getTargetFilename
- Returns the file name to be used when the temporary file is saved.
-
Signatures
public String getTargetFilename()
-
Returns
Filename
setTargetFilename
-
Set the file name to be used when the temporary file is saved.
-
Signatures
public void setTargetFilename(String targetFilename)
-
Parameters
Name Type Description targetFilename java.lang.String Filename -
How to use
FileSaveOption option = new FileSaveOption(); option.setTargetFilename("uploaded_file.txt");
isOverwrite
-
Returns whether or not duplicate files are overwritten.
-
Signatures
public boolean isOverwrite()
-
Returns
true or false(default)
setOverwrite
-
Sets whether to overwrite duplicate files.
When DEXTUploadNJ saves a file, if there are duplicate files with the same file name, the suffix value is automatically appended to the file name. However, in the case of a system that processes many requests at the same time, such as the web, there is a possibility that even the suffix value will be duplicated for a very short time. Therefore, even if the overwrite argument value is false, sometimes file writing may fail. To avoid this situation as much as possible, when saving a file, the file name should be changed to prevent duplicate names from occurring as much as possible without saving the original file name as it is.
-
Signatures
public void setOverwrite(boolean overwrite)
-
Parameters
Name Type Description overwrite boolean true or false -
How to use
FileSaveOption option = new FileSaveOption(); option.setOverwrite(true);
isCopy
-
Returns whether temporary files are removed.
-
Signatures
public boolean isCopy()
-
Returns
true or false(default)
setCopy
-
Sets whether to remove temporary files.
DEXTUploadNJ removes the temporary file immediately after saving the file. Therefore, it cannot be used by calling the FileItem.save method multiple times. If you want to keep the temporary file without deleting it, you can set the copy property to true.
-
Signatures
public void setCopy(boolean copy)
-
Parameters
Name Type Description copy boolean true or false -
How to use
FileSaveOption option = new FileSaveOption(); option.setCopy(true);
isNfc
-
Returns whether the file name is changed to the nfc Unicode normalization form.
-
Signatures
public boolean isNfc()
-
Returns
true or false(default)
setNfc
-
Sets whether to change the file name to nfc Unicode normalization form.
Unlike Windows/Linux, in macOS, file or directory names are managed in the nfd canonical form. For name compatibility between macOS and Windows/Linux, you can set the nfc property to true when nfc changes are required.
-
Signatures
public void setNfc(boolean nfc)
-
Parameters
Name Type Description nfc boolean true or false -
How to use
FileSaveOption option = new FileSaveOption(); option.setNfc(true);