Class InMemoryMultipartFileParameter
- java.lang.Object
-
- com.aspectran.core.activity.request.FileParameter
-
- com.aspectran.web.support.multipart.inmemory.InMemoryMultipartFileParameter
-
public class InMemoryMultipartFileParameter extends FileParameter
This class represents a file item that was received within a multipart/form-data POST request.
-
-
Constructor Summary
Constructors Constructor Description InMemoryMultipartFileParameter(org.apache.commons.fileupload.FileItem fileItem)
Create an instance wrapping the given FileItem.
-
Method Summary
Modifier and Type Method Description void
delete()
Deletes the underlying Commons FileItem instances.byte[]
getBytes()
Return an byte array to read the contents of the file from.java.lang.String
getContentType()
Gets the content type of the data being uploaded.java.io.File
getFile()
java.lang.String
getFileName()
Returns the file name that was uploaded in the multipart form.long
getFileSize()
Returns the file size that was uploaded in the multipart form.java.io.InputStream
getInputStream()
Return an InputStream to read the contents of the file from.java.lang.String
getStorageDescription()
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.java.io.File
renameTo(java.io.File destFile, boolean overwrite)
java.io.File
saveAs(java.io.File destFile, boolean overwrite)
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
-
-
-
-
Method Detail
-
getFile
public java.io.File getFile()
- Overrides:
getFile
in classFileParameter
-
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:
getContentType
in classFileParameter
- Returns:
- the content type
-
getFileName
public java.lang.String 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
public java.io.InputStream getInputStream() throws java.io.IOException
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:
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:
getBytes
in classFileParameter
- Returns:
- the byte array
-
saveAs
public java.io.File saveAs(java.io.File destFile, boolean overwrite) throws java.io.IOException
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:
java.io.IOException
- if an I/O error has occurred
-
renameTo
public java.io.File renameTo(java.io.File destFile, boolean overwrite)
- Overrides:
renameTo
in classFileParameter
-
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
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
-
-