de.deepamehta.plugins.files
Class UploadedFile

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.plugins.files.UploadedFile

public class UploadedFile
extends Object

An uploaded file.

Files are uploaded via the REST API by POSTing multipart/form-data to a resource method which consumes multipart/form-data and has UploadedFile as its entity parameter.

Client-side support: the public API of the Files plugin provides a method dm4c.get_plugin("de.deepamehta.files").open_upload_dialog() that allows the user to choose and upload a file.

Author:
Jörg Richter

Field Summary
private  org.apache.commons.fileupload.FileItem fileItem
           
 
Constructor Summary
UploadedFile(org.apache.commons.fileupload.FileItem fileItem)
           
 
Method Summary
 byte[] getBytes()
          Returns the contents of the uploaded file as an array of bytes.
 InputStream getInputStream()
          Returns an InputStream that can be used to retrieve the contents of the uploaded file.
 String getMediaType()
          Returns the content type passed by the browser or null if not defined.
 String getName()
          Returns the original filename in the client's filesystem, as provided by the browser (or other client software).
 long getSize()
          Returns the size of the file.
 String getString()
          Returns the contents of the uploaded file as a String, using the default character encoding.
 String getString(String encoding)
          Returns the contents of the uploaded file as a String, using the specified encoding.
 String toString()
           
 void write(File file)
          A convenience method to write the uploaded file to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fileItem

private org.apache.commons.fileupload.FileItem fileItem
Constructor Detail

UploadedFile

public UploadedFile(org.apache.commons.fileupload.FileItem fileItem)
Method Detail

getName

public String getName()
Returns the original filename in the client's filesystem, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.


getSize

public long getSize()
Returns the size of the file.


getMediaType

public String getMediaType()
Returns the content type passed by the browser or null if not defined.


getString

public String getString()
Returns the contents of the uploaded file as a String, using the default character encoding.


getString

public String getString(String encoding)
Returns the contents of the uploaded file as a String, using the specified encoding.


getBytes

public byte[] getBytes()
Returns the contents of the uploaded file as an array of bytes.


getInputStream

public InputStream getInputStream()
Returns an InputStream that can be used to retrieve the contents of the uploaded file.


write

public void write(File file)
A convenience method to write the uploaded file to disk.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All Rights Reserved.