Package org.pentaho.platform.web.servlet
Class UploadFileUtils
java.lang.Object
org.pentaho.platform.web.servlet.UploadFileUtils
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUploadFileUtils
(org.pentaho.platform.api.engine.IPentahoSession sessionValue) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkExtension
(String extension, boolean emitMessage) Checks if the given extension is supported.boolean
checkLimits
(long itemSize) boolean
checkLimits
(long itemSize, boolean compressed) Getters and SettersgetPath()
org.apache.commons.fileupload.FileItem
javax.servlet.http.Part
protected String
handleGZip
(File file, boolean fullPath) protected String
protected String
handleTarGZ
(File file) protected boolean
handleUnzip
(File file) protected String
Decompress a zip file and return a list of the file names that were unpackedboolean
boolean
boolean
process()
boolean
process
(InputStream inputStream) process uploading using inputStream instead of UploadedFileItem do not support unzippingprotected String
removeFileName
(String filename) Removes the file name, leaving all extensions of a given filename.void
setFileName
(String value) void
setShouldUnzip
(boolean value) void
setTemporary
(boolean value) void
setUploadedFileItem
(org.apache.commons.fileupload.FileItem value) void
setUploadedPart
(javax.servlet.http.Part uploadedPart) void
-
Field Details
-
DEFAULT_RELATIVE_UPLOAD_FILE_PATH
-
-
Constructor Details
-
UploadFileUtils
public UploadFileUtils(org.pentaho.platform.api.engine.IPentahoSession sessionValue)
-
-
Method Details
-
checkExtension
Checks if the given extension is supported.
A
null
is an invalid extension; to check if a NoExtension is allowed, an empty string must be given.- Parameters:
extension
- the extension to checkemitMessage
- if a message is to be written when an error occurs- Returns:
true
if the given extension is supported,false
if it's an invalid or unsupported extension- Throws:
IOException
-
process
- Throws:
Exception
-
process
process uploading using inputStream instead of UploadedFileItem do not support unzipping- Parameters:
inputStream
-- Returns:
true
if the processing finished successfully andfalse
otherwise- Throws:
Exception
-
handleUnzip
- Throws:
IOException
-
handleZip
Decompress a zip file and return a list of the file names that were unpacked- Parameters:
file
-- Returns:
- Throws:
IOException
-
handleGZip
- Throws:
IOException
-
handleTar
- Throws:
IOException
-
handleTarGZ
- Throws:
IOException
-
checkLimits
- Throws:
IOException
-
checkLimits
- Throws:
IOException
-
removeFileName
Removes the file name, leaving all extensions of a given filename.
Returns
null
if filename isnull
, and an empty string if the filename is empty or has no extensions.The result, if not
null
nor an empty string is sanitized by replacing any character that is not a letter (lower or upper case), a digit (0-9), an underscore ("_"), a dot (".") or a dash ("-"), by an underscore ("_").- Parameters:
filename
- the filename for which we want the extensions- Returns:
- all extensions (sanitized) of the given filename
-
getFileName
Getters and Setters -
setFileName
-
isShouldUnzip
public boolean isShouldUnzip() -
setShouldUnzip
public void setShouldUnzip(boolean value) -
isTemporary
public boolean isTemporary() -
setTemporary
public void setTemporary(boolean value) -
setWriter
-
getWriter
-
setUploadedFileItem
public void setUploadedFileItem(org.apache.commons.fileupload.FileItem value) -
getUploadedFileItem
public org.apache.commons.fileupload.FileItem getUploadedFileItem() -
getUploadedPart
public javax.servlet.http.Part getUploadedPart() -
setUploadedPart
public void setUploadedPart(javax.servlet.http.Part uploadedPart) -
getPath
-
getPathDir
-
getRelativePath
-