public class MultipartUtility extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
USER_AGENT |
| Constructor and Description |
|---|
MultipartUtility(String requestURL,
String charset,
String boundary) |
MultipartUtility(String requestURL,
String charset,
String boundary,
String contentRange)
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(String fieldName,
File uploadFile) |
void |
addFilePart(String fieldName,
File uploadFile,
String fileName)
Adds a upload file section to the request
|
void |
addFilePart(String fieldName,
InputStream inputStream) |
void |
addFilePart(String fieldName,
InputStream inputStream,
String fileName) |
void |
addFormField(String name,
String value)
Adds a form field to the request
|
HttpURLConnection |
execute()
Completes the request and receives response from the server.
|
public static final String USER_AGENT
public MultipartUtility(String requestURL, String charset, String boundary, String contentRange) throws IOException
requestURL - charset - IOExceptionpublic MultipartUtility(String requestURL, String charset, String boundary) throws IOException
IOExceptionpublic void addFormField(String name, String value)
name - field namevalue - field valuepublic void addFilePart(String fieldName, File uploadFile, String fileName) throws IOException
fieldName - name attribute in uploadFile - a File to be uploadedIOExceptionpublic void addFilePart(String fieldName, File uploadFile) throws IOException
IOExceptionpublic void addFilePart(String fieldName, InputStream inputStream, String fileName) throws IOException
IOExceptionpublic void addFilePart(String fieldName, InputStream inputStream) throws IOException
IOExceptionpublic HttpURLConnection execute() throws IOException
IOExceptionCopyright © 2015. All Rights Reserved.