| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.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_CHARSETDefault 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 InputStreamthat 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 OutputStreamthat 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 filesystem| Method Detail | 
|---|
public void delete()
delete in interface FileItempublic byte[] get()
get in interface FileItempublic String getContentType()
getContentType in interface FileItempublic String getFieldName()
getFieldName in interface FileItempublic void setFieldName(String fieldName)
setFieldName in interface FileItemfieldName - the name of the form fieldpublic boolean isFormField()
isFormField in interface FileItempublic void setFormField(boolean isFormField)
setFormField in interface FileItemisFormField - true if the instance represents a simple form field;
 false if it represents an uploaded file
public InputStream getInputStream()
                           throws IOException
InputStream that can be used to
 retrieve the contents of the file.
getInputStream in interface FileItemInputStream 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 FileItemOutputStream that can be used
 for storing the contents of the file
IOException - if an error occurspublic long getSize()
getSize in interface FileItempublic 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 FileItemcharset - 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 FileItemfile - the File into which the uploaded item should be stored
Exception - if an error occurspublic FileItemHeaders getHeaders()
getHeaders in interface FileItemHeadersSupportpublic void setHeaders(FileItemHeaders headers)
setHeaders in interface FileItemHeadersSupportheaders - the file items headerspublic String getCharSet()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||