public class MultipartUtility
extends java.lang.Object
Constructor and Description |
---|
MultipartUtility(java.lang.String requestURL,
java.lang.String charset)
This constructor initializes a new HTTP POST request with content type
is set to multipart/form-data
|
Modifier and Type | Method and Description |
---|---|
void |
addFilePart(java.lang.String fieldName,
java.io.File uploadFile)
Adds a upload file section to the request
|
void |
addFormField(java.lang.String name,
java.lang.String value)
Adds a form field to the request
|
void |
addHeaderField(java.lang.String name,
java.lang.String value)
Adds a header field to the request.
|
java.lang.String |
finish()
Completes the request and receives response from the server.
|
public MultipartUtility(java.lang.String requestURL, java.lang.String charset) throws java.io.IOException
requestURL
- The URL to post tocharset
- The character set to usejava.io.IOException
- If it cannot retrieve an output streampublic void addFormField(java.lang.String name, java.lang.String value)
name
- field namevalue
- field valuepublic void addFilePart(java.lang.String fieldName, java.io.File uploadFile) throws java.io.IOException
fieldName
- name attribute in uploadFile
- a File to be uploadedjava.io.IOException
- Could not access Filepublic void addHeaderField(java.lang.String name, java.lang.String value)
name
- - name of the header fieldvalue
- - value of the header fieldpublic java.lang.String finish() throws java.io.IOException
java.io.IOException
- Non-OK status