You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Description

  • org.joget.apps.form.service.FileUtil
  • Under wflow-core module
  • Utility class to used to handle the files of a form

Code Sample

import java.io.File;
import java.io.IOException;
import org.joget.apps.form.service.FileUtil;

String recordId = "ID-0001";
String tableName = "crm_contact";
String fileName = "profile_image.png";
 
//Get the uploaded file of a form data record
try {
    File profileImage = FileUtil.getFile(fileName, tableName, recordId);
}catch (IOException e) {}

Methods

checkAndUpdateFileName
public static void checkAndUpdateFileName(org.joget.apps.form.model.FormRowSet results, org.joget.apps.form.model.Element form, java.lang.String primaryKeyValue)

Method used to check for the duplicate file name of files in the FormRowSet object against the existing files in the target upload directory.

It will update the file name by appending with number if found duplicated.

checkAndUpdateFileName
public static void checkAndUpdateFileName(org.joget.apps.form.model.FormRowSet results, java.lang.String tableName, java.lang.String primaryKeyValue)

Method used to check for the duplicate file name of files in the FormRowSet object against the existing files in the target upload directory.

It will update the file name by appending with number if found duplicated.

getApplicationContext
public static org.springframework.context.ApplicationContext getApplicationContext()

Utility method to retrieve the ApplicationContext of the system

getFile
public static java.io.File getFile(String fileName, org.joget.apps.form.model.Element form, java.lang.String primaryKeyValue) throws java.io.IOException

Gets the file from target upload directory of a form data record

getFile
public static java.io.File getFile(java.lang.String fileName, java.lang.String tableName, java.lang.String primaryKeyValue) throws java.io.IOException

Gets the file from target upload directory of a form data record

getTableName
public static java.lang.String getTableName (org.joget.apps.form.model.Element form)

Method used to gets the table name from the properties of a Form object

getUploadPath
public static java.lang.String getUploadPath(org.joget.apps.form.model.Element form, java.lang.String primaryKeyValue)

Gets the target upload directory of a form data record

getUploadPath
public static java.lang.String getUploadPath(java.lang.String tableName, java.lang.String primaryKeyValue)

Gets the target upload directory of a form data record

storeFile
public static void storeFile(java.io.File file, java.lang.String tableName, java.lang.String primaryKeyValue)

Store file to target upload directory of a form data record

storeFile
public static java.io.File getFile(java.lang.String fileName, org.joget.apps.form.model.Element form, java.lang.String primaryKeyValue) throws java.io.IOException

Gets the file from target upload directory of a form data record

storeFile
public static void storeFile(org.springframework.web.multipart.MultipartFile file, org.joget.apps.form.model.Element form, java.lang.String primaryKeyValue)

Store file to target upload directory of a form data record

storeFileFromFormRowSet
public static void storeFileFromFormRowSet(org.joget.apps.form.model.FormRowSet results, org.joget.apps.form.model.Element form, java.lang.String primaryKeyValue)

Store files in the FormRowSet to target upload directory of a form data record

storeFileFromFormRowSet
public static void storeFileFromFormRowSet(org.joget.apps.form.model.FormRowSet results, java.lang.String tableName, java.lang.String primaryKeyValue)

Store files in the FormRowSet to target upload directory of a form data record

validateFileName
public static java.lang.String validateFileName(java.lang.String fileName, java.lang.String path, java.util.Set<java.lang.String> existedFileName)

Validate the file name against the existing files in the target upload directory.

Parameters:

existedFileName - a set of file names which not yet exist in the target upload directory but the current checking file should not has the same file name in it. 

Return the new file name with number appended when duplicate file is found.

  • No labels