Package io.guise.framework.model
Class FileItemResourceImport
java.lang.Object
io.guise.framework.model.FileItemResourceImport
- All Implemented Interfaces:
ResourceImport
A resource import that accesses a web file upload through the Apache commons file item interface.
- Author:
- Garret Wilson
- See Also:
-
FileItem
-
Constructor Summary
ConstructorDescriptionFileItemResourceImport
(org.apache.commons.fileupload.FileItem fileItem) File item constructor. -
Method Summary
Modifier and TypeMethodDescriptionlong
com.globalmentor.net.MediaType
protected org.apache.commons.fileupload.FileItem
Retrieves an input stream to the resource.getName()
Returns the simple name, such as the filename, of the resource.boolean
void
Convenience method for storing the imported resource in a file.toString()
-
Constructor Details
-
FileItemResourceImport
public FileItemResourceImport(org.apache.commons.fileupload.FileItem fileItem) File item constructor.- Parameters:
fileItem
- The Apache commons file item representing a file upload.- Throws:
NullPointerException
- if the given file item isnull
.
-
-
Method Details
-
getFileItem
protected org.apache.commons.fileupload.FileItem getFileItem()- Returns:
- The Apache commons file item representing a file upload.
-
isImported
public boolean isImported()- Specified by:
isImported
in interfaceResourceImport
- Returns:
- Whether the resource has been accessed, either by retrieving its input stream or by storing the resource in a file.
-
getName
- Specified by:
getName
in interfaceResourceImport
- Returns:
- The name of the resource, which may be, for example, a simple name, a path and filename, or
null
if the name is not known. - See Also:
-
getSimpleName
Description copied from interface:ResourceImport
Returns the simple name, such as the filename, of the resource. The returned string does not include any path information.- Specified by:
getSimpleName
in interfaceResourceImport
- Returns:
- The simple name of the resource, or
null
if the name is not known. - See Also:
-
getContentType
public com.globalmentor.net.MediaType getContentType()- Specified by:
getContentType
in interfaceResourceImport
- Returns:
- The content type of the resource to be imported, or
null
if the content type of the resource is not known.
-
getContentLength
public long getContentLength()- Specified by:
getContentLength
in interfaceResourceImport
- Returns:
- The length of the resource to be imported, or -1 if the length of the resource is not known.
-
getInputStream
Description copied from interface:ResourceImport
Retrieves an input stream to the resource. There can only be at most a single call to this method orResourceImport.store(File)
.- Specified by:
getInputStream
in interfaceResourceImport
- Returns:
- An input stream to the resource to be imported.
- Throws:
IOException
- if there is an error getting an input stream to the resource.
-
store
Description copied from interface:ResourceImport
Convenience method for storing the imported resource in a file. Depending on the implementation, this may allow greater efficiency than reading from the stream. There can only be at most a single call to this method orResourceImport.getInputStream()
.- Specified by:
store
in interfaceResourceImport
- Parameters:
file
- The file to which the resource should be written.- Throws:
IOException
- If there is an error writing the resource to the file.
-
toString
-