Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Description

  • org.joget.commons.util.FileStore
  • Under wflow-commons module
  • Utility class to retrieve plugin propertise value and i18n message 

Code Sample

Code Block
languagejava
import org.joget.commons.util.FileLimitException;
import org.joget.commons.util.FileStore;
import org.joget.commons.util.LogUtil;
import org.springframework.web.multipart.MultipartFile;


String uploadFieldName = "csvImport";
 
//Gets file
try {
    MultipartFile csvFile = FileStore.getFile(uploadFieldName);
} catch (FileLimitException e) {
    LogUtil.error("", e, "File received from " + uploadFieldName + " is exceeded file size limit of " + FileStore.getFileSizeLimit() + "MB.");
}

Methods

clear
public static void clear()

Method used by the system to clear the ThreadLocal object after a HTTP request is finish processing

getFile
public static org.springframework.web.multipart.MultipartFile getFile(java.lang.String name) throws org.joget.commons.util.FileLimitException

Convenient method to retrieves the posted file in current HTTP request based on field name

getFiles
public static org.springframework.web.multipart.MultipartFile[] getFiles(java.lang.String name) throws org.joget.commons.util.FileLimitException

Method to retrieves the posted files in current HTTP request based on field name

getFileErrorList
public static java.util.Collection<java.lang.String> getFileErrorList()

Gets a list of the field name which has file exceed the file limit in the current HTTP request

getFileMap
public static java.util.Map<java.lang.String, org.springframework.web.multipart.MultipartFile[]> getFileMap()

Gets all the posted files of the current HTTP request

Return a map of field name & its files

getFileNames
public static java.util.Iterator<java.lang.String> getFileNames()

Gets the Iterator of all upload field name of the current HTTP request

getFileSizeLimit
public static int getFileSizeLimit()

Get the file size limit of the system in MB

getFileSizeLimitLong
public static long getFileSizeLimitLong()

Get the file size limit of the system in byte

setFileMap
public static void setFileMap(java.util.Map<java.lang.String, org.springframework.web.multipart.MultipartFile[]> fileMap)

Sets the posted files in a HTTP request to a ThreadLocal object for temporary storing.

Parameters:

fileMap - a map of field name & its files

updateFileSizeLimit
public static void updateFileSizeLimit()

Method call to refresh the file size limit based on system setting