Class CommonsMultipartFileParameter
java.lang.Object
com.aspectran.core.activity.request.FileParameter
com.aspectran.web.support.multipart.commons.CommonsMultipartFileParameter
This 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
ConstructorsConstructorDescriptionCommonsMultipartFileParameter
(org.apache.commons.fileupload.FileItem fileItem) Create an instance wrapping the given FileItem. -
Method Summary
Modifier and TypeMethodDescriptionvoid
delete()
Deletes the underlying Commons FileItem instances.byte[]
getBytes()
Return an byte array to read the contents of the file from.Gets the content type of the data being uploaded.getFile()
Returns the file name that was uploaded in the multipart form.long
Returns the file size that was uploaded in the multipart form.Return an InputStream to read the contents of the file from.Return a description for the storage location of the multipart content.void
release()
Sets the access permission that allow write operations on the file associated with this FileParameter.Save an uploaded file as a given destination file.Methods inherited from class com.aspectran.core.activity.request.FileParameter
determineDestinationFile, getSavedFile, isRefused, releaseSavedFile, renameTo, rollback, saveAs, setRefused, setSavedFile, toString
-
Constructor Details
-
CommonsMultipartFileParameter
Create an instance wrapping the given FileItem.- Parameters:
fileItem
- the FileItem to wrap
-
-
Method Details
-
getFile
- Overrides:
getFile
in classFileParameter
-
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:
getContentType
in classFileParameter
- Returns:
- the content type
-
getFileName
Returns the file name that was uploaded in the multipart form.- Overrides:
getFileName
in classFileParameter
- Returns:
- the file name
-
getFileSize
public long getFileSize()Returns the file size that was uploaded in the multipart form.- Overrides:
getFileSize
in classFileParameter
- Returns:
- the file size
-
getInputStream
Return an InputStream to read the contents of the file from.- Overrides:
getInputStream
in classFileParameter
- Returns:
- the contents of the file as stream, or an empty stream if empty
- Throws:
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:
getBytes
in classFileParameter
- Returns:
- the byte array
-
saveAs
Save an uploaded file as a given destination file.- Overrides:
saveAs
in classFileParameter
- Parameters:
destFile
- the destination fileoverwrite
- whether to overwrite if it already exists- Returns:
- a saved file
- Throws:
IOException
- if an I/O error has occurred
-
renameTo
- Overrides:
renameTo
in classFileParameter
- Throws:
IOException
-
delete
public void delete()Deletes the underlying Commons FileItem instances.- Overrides:
delete
in classFileParameter
-
release
public void release()Description copied from class:FileParameter
Sets the access permission that allow write operations on the file associated with this FileParameter.- Overrides:
release
in classFileParameter
-
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
-