Class MultipartUtility
java.lang.Object
com.blackberry.workspaces.sdk.api.MultipartUtility
public class MultipartUtility extends Object
This utility class provides an abstraction layer for sending multipart HTTP POST requests to a web server.
- Author:
- www.codejava.net
-
Constructor Summary
Constructors Constructor Description MultipartUtility(String requestURL, String charset)
This constructor initializes a new HTTP POST request with content type is set to multipart/form-data -
Method Summary
Modifier and Type Method Description void
addFilePart(String fieldName, File uploadFile)
Adds a upload file section to the requestvoid
addFormField(String name, String value)
Adds a form field to the requestvoid
addHeaderField(String name, String value)
Adds a header field to the request.List<String>
finish()
Completes the request and receives response from the server.
-
Constructor Details
-
MultipartUtility
This constructor initializes a new HTTP POST request with content type is set to multipart/form-data- Parameters:
requestURL
-charset
-- Throws:
IOException
-
-
Method Details
-
addFormField
Adds a form field to the request- Parameters:
name
- field namevalue
- field value
-
addFilePart
Adds a upload file section to the request- Parameters:
fieldName
- name attribute inuploadFile
- a File to be uploaded- Throws:
IOException
-
addHeaderField
Adds a header field to the request.- Parameters:
name
- - name of the header fieldvalue
- - value of the header field
-
finish
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.
- Throws:
IOException
-