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 booleancheckExtension(String extension, boolean emitMessage) Checks if the given extension is supported.booleancheckLimits(long itemSize) booleancheckLimits(long itemSize, boolean compressed) Getters and SettersgetPath()org.apache.commons.fileupload.FileItemjavax.servlet.http.Partprotected StringhandleGZip(File file, boolean fullPath) protected Stringprotected StringhandleTarGZ(File file) protected booleanhandleUnzip(File file) protected StringDecompress a zip file and return a list of the file names that were unpackedbooleanbooleanbooleanprocess()booleanprocess(InputStream inputStream) process uploading using inputStream instead of UploadedFileItem do not support unzippingprotected StringremoveFileName(String filename) Removes the file name, leaving all extensions of a given filename.voidsetFileName(String value) voidsetShouldUnzip(boolean value) voidsetTemporary(boolean value) voidsetUploadedFileItem(org.apache.commons.fileupload.FileItem value) voidsetUploadedPart(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
nullis 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:
trueif the given extension is supported,falseif 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:
trueif the processing finished successfully andfalseotherwise- 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
nullif filename isnull, and an empty string if the filename is empty or has no extensions.The result, if not
nullnor 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
-