public class FileUploadUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getValidFilename(String filename) |
static String |
getValidFilePath(String filePath) |
static boolean |
isSystemWindows() |
static boolean |
isValidType(FileUpload fileUpload,
String fileName,
InputStream inputStream)
Check if an uploaded file meets all specifications regarding its filename and content type.
|
static void |
performVirusScan(javax.faces.context.FacesContext facesContext,
FileUpload fileUpload,
InputStream inputStream) |
public static String getValidFilePath(String filePath) throws org.owasp.esapi.errors.ValidationException
org.owasp.esapi.errors.ValidationException
public static boolean isSystemWindows()
public static boolean isValidType(FileUpload fileUpload, String fileName, InputStream inputStream)
FileUploadBase.getAllowTypes()
as well as FileUploadBase.getAccept()
and uses the installed FileTypeDetector
implementation.
For most reliable content type checking it's recommended to plug in Apache Tika as an implementation.fileUpload
- the fileUpload componentfileName
- the name of the uploaded fileinputStream
- the input stream to receive the file's content fromtrue
, if all validations regarding filename and content type passed, false
elsepublic static void performVirusScan(javax.faces.context.FacesContext facesContext, FileUpload fileUpload, InputStream inputStream) throws VirusException
VirusException
Copyright © 2019. All rights reserved.