|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.extras.gae.MemoryFileItem
public class MemoryFileItem
Provides an In-Memory FileItem implementation which represents a file or form item that was received within a multipart/form-data POST request.
This FileItem implementation can safely be used with Google App Engine (GAE) since the file content is not written to disk. The MemoryFileItem is based on the Commons FileUpload project.
Field Summary | |
---|---|
static String |
DEFAULT_CHARSET
Default content charset to be used when no explicit charset parameter is provided by the sender. |
Constructor Summary | |
---|---|
MemoryFileItem(String fieldName,
String contentType,
boolean isFormField,
String fileName)
Constructs a new MemoryFileItem for the given fieldName, contentType isFormField and fileName parameters. |
Method Summary | |
---|---|
void |
delete()
This method does nothing since the file is stored in memory only. |
byte[] |
get()
Returns the contents of the file item as an array of bytes. |
String |
getCharSet()
Returns the content charset passed by the agent or null if not defined. |
String |
getContentType()
Returns the content type passed by the browser or null if not defined. |
String |
getFieldName()
Returns the name of the field in the multipart form corresponding to this file item. |
FileItemHeaders |
getHeaders()
Returns the file item headers. |
InputStream |
getInputStream()
Returns an InputStream that can be used to
retrieve the contents of the file. |
String |
getName()
Returns the original filename in the client's filesystem, as provided by the browser (or other client software). |
OutputStream |
getOutputStream()
Returns an OutputStream that can be used for
storing the contents of the file. |
long |
getSize()
Returns the size of the file item, in bytes. |
String |
getString()
Returns the contents of the file as a String, using the default character encoding. |
String |
getString(String charset)
Returns the contents of the file as a String, using the specified encoding. |
boolean |
isFormField()
Determines whether or not a FileItem instance represents a simple form field. |
boolean |
isInMemory()
Provides a hint as to whether or not the file contents will be read from memory. |
void |
setFieldName(String fieldName)
Sets the field name used to reference this file item. |
void |
setFormField(boolean isFormField)
Specifies whether or not a FileItem instance represents a simple form field. |
void |
setHeaders(FileItemHeaders headers)
Sets the file item headers. |
void |
write(File file)
This method does nothing since the file is stored in memory only. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_CHARSET
Constructor Detail |
---|
public MemoryFileItem(String fieldName, String contentType, boolean isFormField, String fileName)
fieldName
- the name of the form field as provided by the browsercontentType
- the content type passed by the browserisFormField
- specifies whether or not this item is a simple form fieldfileName
- the original filename in the user's filesystemMethod Detail |
---|
public void delete()
delete
in interface FileItem
public byte[] get()
get
in interface FileItem
public String getContentType()
getContentType
in interface FileItem
public String getFieldName()
getFieldName
in interface FileItem
public void setFieldName(String fieldName)
setFieldName
in interface FileItem
fieldName
- the name of the form fieldpublic boolean isFormField()
isFormField
in interface FileItem
public void setFormField(boolean isFormField)
setFormField
in interface FileItem
isFormField
- true if the instance represents a simple form field;
false if it represents an uploaded filepublic InputStream getInputStream() throws IOException
InputStream
that can be used to
retrieve the contents of the file.
getInputStream
in interface FileItem
InputStream
that can be used to
retrieve the contents of the file
IOException
- if an error occurspublic String getName()
String fileName = fileItem.getName(); if (fileName != null) { filename = FilenameUtils.getName(filename); }
getName
in interface FileItem
public OutputStream getOutputStream() throws IOException
OutputStream
that can be used for
storing the contents of the file.
getOutputStream
in interface FileItem
OutputStream
that can be used
for storing the contents of the file
IOException
- if an error occurspublic long getSize()
getSize
in interface FileItem
public String getString()
get()
to retrieve the
contents of the file.
getString
in interface FileItem
public String getString(String charset) throws UnsupportedEncodingException
get()
to retrieve the contents of the
file.
getString
in interface FileItem
charset
- the charset to use
UnsupportedEncodingException
- if the requested character
encoding is not available.public boolean isInMemory()
isInMemory
in interface FileItem
public void write(File file) throws Exception
write
in interface FileItem
file
- the File into which the uploaded item should be stored
Exception
- if an error occurspublic FileItemHeaders getHeaders()
getHeaders
in interface FileItemHeadersSupport
public void setHeaders(FileItemHeaders headers)
setHeaders
in interface FileItemHeadersSupport
headers
- the file items headerspublic String getCharSet()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |