www.dextsolution.com
DEXTUPLOAD
JK
menu toggleReference > dextuploadjk > engine > FileSaveOption

dextuploadjk.engine
Class FileSaveOption

Minimum version
1.0.0
Minimum environment
Java 17, Jakarta EE 9+
Description

Class to set options for saving temporary files.

FileSaveOption option = new FileSaveOption();
option.setTargetDirectoryPath("/home/user/others/");
option.setTargetFilename("uploaded_file.txt");
item.save(option);
Constructor

FileSaveOption

  • Creates an object of class FileSaveOption.
  • 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 The filename to use when saving the temporary file
    overwrite boolean Whether to overwrite duplicate files
    copy boolean Whether to remove temporary files
    nfc boolean Whether to change to Unicode normalized form
Methods

getTargetDirectoryPath

  • Returns the directory path to save the file.
  • Signatures

    public String getTargetDirectoryPath()
  • Return

    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
  • Uses

    FileSaveOption option = new FileSaveOption();
    option.setTargetDirectoryPath("/home/user/others/");

getTargetFilename

  • Returns the filename to use when temporary files are saved.
  • Signatures

    public String getTargetFilename()
  • Return

    File name

setTargetFilename

  • Sets the filename to use when the file is saved.

  • Signatures

    public void setTargetFilename(String targetFilename)
  • Parameters

    Name Type Description
    targetFilename java.lang.String File name
  • Uses

    FileSaveOption option = new FileSaveOption();
    option.setTargetFilename("uploaded_file.txt");

isOverwrite

  • Returns whether duplicate files are overwritten.

  • Signatures

    public boolean isOverwrite()
  • Return

    true or false (default)

setOverwrite

  • Sets whether duplicate files are overwritten.

    When DEXTUploadJK saves a file, it automatically appends a suffix value to the file name if there are duplicate files with the same file name. However, in a system that processes many requests simultaneously, such as the web, even the suffix value can become redundant in a very short time. Therefore, file writes can often fail, even when the overwrite argument is false. To avoid this situation as much as possible, when saving a file, it should be renamed rather than saved with the original filename and processed to avoid duplicate names as much as possible.

  • Signatures

    public void setOverwrite(boolean overwrite)
  • Parameters

    Name Type Description
    overwrite boolean true or false
  • Uses

    FileSaveOption option = new FileSaveOption();
    option.setOverwrite(true);

isCopy

  • Returns whether to remove temporary files.

  • Signatures

    public boolean isCopy()
  • Return

    true or false (default)

setCopy

  • Sets whether to remove temporary files.

    DEXTUploadJK removes temporary files immediately after saving the file, which prevents you from 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
  • Uses

    FileSaveOption option = new FileSaveOption();
    option.setCopy(true);

isNfc

  • Returns whether the file name was renamed to the NFC Unicode normalized form.

  • Signatures

    public boolean isNfc()
  • Return

    true or false (default)

setNfc

  • Sets whether to change the file name to NFC Unicode normalized form.

    Unlike Windows/Linux, macOS uses the nfd canonical form to manage file or directory names. To make the name compatible between macOS and Windows/Linux, you can set the nfc property to true when you need to make nfc changes.

  • Signatures

    public void setNfc(boolean nfc)
  • Parameters

    Name Type Description
    nfc boolean true or false
  • Uses

    FileSaveOption option = new FileSaveOption();
    option.setNfc(true);