Secure iNet Factory

com.jscape.inet.http
Class HttpFileUpload

java.lang.Object
  extended bycom.jscape.inet.mime.MimeMessage
      extended bycom.jscape.inet.http.HttpRequest
          extended bycom.jscape.inet.http.HttpFileUpload
All Implemented Interfaces:
MimeConstants, java.io.Serializable

public class HttpFileUpload
extends HttpRequest

Implements methods for emulating a web browser and performing HTTP file upload based on specifications defined in RFC 1867.

Example Usage:

 Http http = new Http();
 HttpFileUpload request = new HttpFileUpload("http://www.myserver.com/cgi-bin/upload.cgi");
 request.addParameter("name", "John Doe");
 request.setFile("picture", "joe.gif", new File("/home/joe/joe.gif");
 HttpResponse response = http.getResponse(request);
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.jscape.inet.mime.MimeConstants
COLON, CRLF, EQUALS, QUESTION_MARK, SEMI_COLON, SPACE, TAB
 
Constructor Summary
HttpFileUpload(java.lang.String url)
          Constructs a new HttpFileUpload instance.
 
Method Summary
 void addParameter(HttpParameter parameter)
          Adds a query parameter to HttpFileUpload.
 void addParameter(java.lang.String name, java.lang.String value)
          Adds a query parameter to HttpFileUpload.
 void setFile(java.lang.String fieldName, java.lang.String filename, byte[] data)
          Sets the file to upload for this HttpFileUpload.
 void setFile(java.lang.String fieldName, java.lang.String fileName, java.io.File file)
          Sets the file to upload for this HttpFileUpload.
 
Methods inherited from class com.jscape.inet.http.HttpRequest
addCookie, addHeader, addHeader, addReplaceHeader, addReplaceHeader, addReplaceParameter, addReplaceParameter, clearCookies, clearParameters, getHttpVersion, getMessage, getMethod, getParameters, getProxyHost, getProxyPort, getProxyUsername, getURL, getUserAgent, isUTF8, setBasicAuthentication, setHttpVersion, setMethod, setProxyHost, setProxyLogin, setProxyPort, setURL, setUserAgent, setUTF8
 
Methods inherited from class com.jscape.inet.mime.MimeMessage
addPart, getBody, getBodyData, getBoundary, getContentTransferEncoding, getContentType, getHeader, getHeaders, getHeaders, getHeaderValue, getPart, getParts, getRawBodyData, removeHeader, removePart, removeParts, setBody, setBody, setBody, setBody, setContentType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpFileUpload

public HttpFileUpload(java.lang.String url)
               throws HttpException
Constructs a new HttpFileUpload instance.

Parameters:
url - the URL to post the file upload to
Throws:
HttpException - if a MIME related parsing error occurs
Method Detail

addParameter

public void addParameter(java.lang.String name,
                         java.lang.String value)
Adds a query parameter to HttpFileUpload. HTTP query parameters are typically used in submitting form data for processing by a CGI or servlet resident on the HTTP server. Names of query parameters need not be unique.

Overrides:
addParameter in class HttpRequest
Parameters:
name - the name of the parameter to add.
value - the value of the parameter to add.

addParameter

public void addParameter(HttpParameter parameter)
Adds a query parameter to HttpFileUpload. HTTP query parameters are typically used in submitting form data for processing by a CGI or servlet resident on the HTTP server. Names of query parameters need not be unique.

Overrides:
addParameter in class HttpRequest
Parameters:
parameter - the HttpParameter to add
See Also:
HttpParameter

setFile

public void setFile(java.lang.String fieldName,
                    java.lang.String fileName,
                    java.io.File file)
             throws HttpException
Sets the file to upload for this HttpFileUpload.

Parameters:
fieldName - the name of the field, as specified in HTML INPUT TYPE=FILE tag
fileName - the value to set the MIME filename attribute to
file - the File object of the file to be added
Throws:
HttpException - if file is not found

setFile

public void setFile(java.lang.String fieldName,
                    java.lang.String filename,
                    byte[] data)
             throws HttpException
Sets the file to upload for this HttpFileUpload.

Parameters:
fieldName - the name of the field, as specified in HTML INPUT TYPE=FILE tag
filename - the value to set the MIME filename attribute to
data - the data representing the file to upload
Throws:
HttpException - if file is not found

Secure iNet Factory

Copyright JSCAPE 1999-2008 All Rights Reserved