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 Details

    • MultipartUtility

      public 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 -
      Throws:
      IOException
  • Method Details

    • addFormField

      public void addFormField​(String name, String value)
      Adds a form field to the request
      Parameters:
      name - field name
      value - field value
    • addFilePart

      public void addFilePart​(String fieldName, File uploadFile) throws IOException
      Adds a upload file section to the request
      Parameters:
      fieldName - name attribute in
      uploadFile - a File to be uploaded
      Throws:
      IOException
    • addHeaderField

      public void 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
    • finish

      public List<String> 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.
      Throws:
      IOException