public class UploadFileUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_RELATIVE_UPLOAD_FILE_PATH |
Constructor and Description |
---|
UploadFileUtils(org.pentaho.platform.api.engine.IPentahoSession sessionValue) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkExtension(String extension,
boolean emitMessage)
Checks if the given extension is supported.
|
boolean |
checkLimits(long itemSize) |
boolean |
checkLimits(long itemSize,
boolean compressed) |
String |
getFileName()
Getters and Setters
|
String |
getPath() |
File |
getPathDir() |
String |
getRelativePath() |
org.apache.commons.fileupload.FileItem |
getUploadedFileItem() |
Writer |
getWriter() |
protected String |
handleGZip(File file,
boolean fullPath) |
protected String |
handleTar(File file) |
protected String |
handleTarGZ(File file) |
protected boolean |
handleUnzip(File file) |
protected String |
handleZip(File file)
Decompress a zip file and return a list of the file names that were unpacked
|
boolean |
isShouldUnzip() |
boolean |
isTemporary() |
boolean |
process() |
boolean |
process(InputStream inputStream)
process uploading using inputStream instead of UploadedFileItem do not support unzipping
|
protected 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 |
setWriter(Writer value) |
public static final String DEFAULT_RELATIVE_UPLOAD_FILE_PATH
public UploadFileUtils(org.pentaho.platform.api.engine.IPentahoSession sessionValue)
protected boolean checkExtension(String extension, boolean emitMessage) throws IOException
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.
extension
- the extension to checkemitMessage
- if a message is to be written when an error occurstrue
if the given extension is supported, false
if it's an invalid
or unsupported extensionIOException
public boolean process(InputStream inputStream) throws Exception
inputStream
- true
if the processing finished successfully and false
otherwiseException
protected boolean handleUnzip(File file) throws IOException
IOException
protected String handleZip(File file) throws IOException
file
- IOException
protected String handleGZip(File file, boolean fullPath) throws IOException
IOException
protected String handleTar(File file) throws IOException
IOException
protected String handleTarGZ(File file) throws IOException
IOException
public boolean checkLimits(long itemSize) throws IOException
IOException
public boolean checkLimits(long itemSize, boolean compressed) throws IOException
IOException
protected String removeFileName(String filename)
Removes the file name, leaving all extensions of a given filename.
Returns null
if filename is null
, 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
("_").
filename
- the filename for which we want the extensionspublic String getFileName()
public void setFileName(String value)
public boolean isShouldUnzip()
public void setShouldUnzip(boolean value)
public boolean isTemporary()
public void setTemporary(boolean value)
public void setWriter(Writer value)
public Writer getWriter()
public void setUploadedFileItem(org.apache.commons.fileupload.FileItem value)
public org.apache.commons.fileupload.FileItem getUploadedFileItem()
public String getPath()
public File getPathDir()
public String getRelativePath()
Copyright © 2021 Hitachi Vantara. All rights reserved.