Class CommonsMultipartFileParameter
- java.lang.Object
-
- com.aspectran.core.activity.request.FileParameter
-
- com.aspectran.web.support.multipart.commons.CommonsMultipartFileParameter
-
public class CommonsMultipartFileParameter extends com.aspectran.core.activity.request.FileParameterThis class represents a file item that was received within a multipart/form-data POST request.Created: 2008. 04. 11 PM 8:55:25
-
-
Constructor Summary
Constructors Constructor Description CommonsMultipartFileParameter(org.apache.commons.fileupload.FileItem fileItem)Create an instance wrapping the given FileItem.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Deletes the underlying Commons FileItem instances.byte[]getBytes()Return an byte array to read the contents of the file from.java.lang.StringgetContentType()Gets the content type of the data being uploaded.java.io.FilegetFile()java.lang.StringgetFileName()Returns the file name that was uploaded in the multipart form.longgetFileSize()Returns the file size that was uploaded in the multipart form.java.io.InputStreamgetInputStream()Return an InputStream to read the contents of the file from.java.lang.StringgetStorageDescription()Return a description for the storage location of the multipart content.voidrelease()java.io.FilerenameTo(java.io.File destFile, boolean overwrite)java.io.FilesaveAs(java.io.File destFile, boolean overwrite)Save an uploaded file as a given destination file.
-
-
-
Method Detail
-
getFile
public java.io.File getFile()
- Overrides:
getFilein classcom.aspectran.core.activity.request.FileParameter
-
getContentType
public java.lang.String getContentType()
Gets the content type of the data being uploaded. This is never null, and defaults to "content/unknown" when the mime type of the data couldn't be determined and was not set manually.- Overrides:
getContentTypein classcom.aspectran.core.activity.request.FileParameter- Returns:
- the content type
-
getFileName
public java.lang.String getFileName()
Returns the file name that was uploaded in the multipart form.- Overrides:
getFileNamein classcom.aspectran.core.activity.request.FileParameter- Returns:
- the file name
-
getFileSize
public long getFileSize()
Returns the file size that was uploaded in the multipart form.- Overrides:
getFileSizein classcom.aspectran.core.activity.request.FileParameter- Returns:
- the file size
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionReturn an InputStream to read the contents of the file from.- Overrides:
getInputStreamin classcom.aspectran.core.activity.request.FileParameter- Returns:
- the contents of the file as stream, or an empty stream if empty
- Throws:
java.io.IOException- in case of access errors (if the temporary store fails)
-
getBytes
public byte[] getBytes()
Return an byte array to read the contents of the file from.- Overrides:
getBytesin classcom.aspectran.core.activity.request.FileParameter- Returns:
- the byte array
-
saveAs
public java.io.File saveAs(java.io.File destFile, boolean overwrite) throws java.io.IOExceptionSave an uploaded file as a given destination file.- Overrides:
saveAsin classcom.aspectran.core.activity.request.FileParameter- Parameters:
destFile- the destination fileoverwrite- whether to overwrite if it already exists- Returns:
- a saved file
- Throws:
java.io.IOException- if an I/O error has occurred
-
renameTo
public java.io.File renameTo(java.io.File destFile, boolean overwrite) throws java.io.IOException- Overrides:
renameToin classcom.aspectran.core.activity.request.FileParameter- Throws:
java.io.IOException
-
delete
public void delete()
Deletes the underlying Commons FileItem instances.- Overrides:
deletein classcom.aspectran.core.activity.request.FileParameter
-
release
public void release()
- Overrides:
releasein classcom.aspectran.core.activity.request.FileParameter
-
getStorageDescription
public java.lang.String getStorageDescription()
Return a description for the storage location of the multipart content. Tries to be as specific as possible: mentions the file location in case of a temporary file.- Returns:
- a description for the storage location of the multipart content
-
-