PulpCore

pulpcore.net
Class Upload

java.lang.Object
  extended by pulpcore.net.Upload
All Implemented Interfaces:
Runnable

public class Upload
extends Object
implements Runnable

The Upload class represents name/value pairs for sending to an HTTP server via the POST method (multipart form). Values can be either plain text or files.


Constructor Summary
Upload(URL url)
          Creates a new Upload object.
 
Method Summary
 void addField(String name, String value)
          Add a plain text form field to this form.
 void addFields(Map fields)
          Adds plain text form fields to this form.
 void addFile(String name, String fileName, String mimeType, byte[] fileData)
          Add a data file to this form.
 String getResponse()
           
 boolean isCompleted()
           
 void run()
           
 void sendNow()
          Write the form to an URL via the POST method in the current thread.
 void start()
          Write the form to an URL via the POST method in a new thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Upload

public Upload(URL url)
Creates a new Upload object.

Parameters:
url - the URL to send the POST to.
Method Detail

addFields

public void addFields(Map fields)
Adds plain text form fields to this form.


addField

public void addField(String name,
                     String value)
Add a plain text form field to this form.


addFile

public void addFile(String name,
                    String fileName,
                    String mimeType,
                    byte[] fileData)
Add a data file to this form.


run

public void run()
Specified by:
run in interface Runnable

start

public void start()
Write the form to an URL via the POST method in a new thread. The form is sent using the multipart/form-data encoding. The response, if any, can be retrieved using getResponse().


sendNow

public void sendNow()
             throws IOException
Write the form to an URL via the POST method in the current thread. The form is sent using the multipart/form-data encoding. The response, if any, can be retrieved using getResponse().

Throws:
IOException

getResponse

public String getResponse()

isCompleted

public boolean isCompleted()
Returns:
true if a call to send() or sendNow() has completed.

PulpCore

Copyright © 2007-2008 Interactive Pulp, LLC.