Project CASUAL
API for CASUAL
 All Classes Namespaces Functions Variables
Public Member Functions | List of all members
com.casual_dev.caspac_uploader.MultipartUtility Class Reference

Public Member Functions

 MultipartUtility (String requestURL, String charset) throws IOException
 
void addFormField (String name, String value)
 
void addFilePart (String fieldName, File uploadFile) throws IOException
 
void addHeaderField (String name, String value)
 
List< String > finish () throws IOException
 

Detailed Description

This utility class provides an abstraction layer for sending multipart HTTP POST requests to a web server.

Author
www.codejava.net

Constructor & Destructor Documentation

com.casual_dev.caspac_uploader.MultipartUtility.MultipartUtility ( String  requestURL,
String  charset 
) throws IOException

This constructor initializes a new HTTP POST request with content type is set to multipart/form-data

Parameters
requestURL
charset
Exceptions
IOException

Member Function Documentation

void com.casual_dev.caspac_uploader.MultipartUtility.addFilePart ( String  fieldName,
File  uploadFile 
) throws IOException

Adds a upload file section to the request

Parameters
fieldNamename attribute in input type="file" name="..."
uploadFilea File to be uploaded
Exceptions
IOException
void com.casual_dev.caspac_uploader.MultipartUtility.addFormField ( String  name,
String  value 
)

Adds a form field to the request

Parameters
namefield name
valuefield value
void com.casual_dev.caspac_uploader.MultipartUtility.addHeaderField ( String  name,
String  value 
)

Adds a header field to the request.

Parameters
name- name of the header field
value- value of the header field
List<String> com.casual_dev.caspac_uploader.MultipartUtility.finish ( ) throws IOException

Completes the request and receives response from the server.

Returns
a list of Strings as response in case the server returned status OK, otherwise an exception is thrown.
Exceptions
IOException

The documentation for this class was generated from the following file: