public class MultipartUtility extends Object
| Constructor and Description |
|---|
MultipartUtility(String requestURL,
String charset,
Map<String,String> headers)
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)
Adds a upload file section to the request
|
void |
addFormField(String name,
String value)
Adds a form field to the request
|
void |
addHeaderField(String name,
String value)
Adds a header field to the request.
|
String |
finish()
Completes the request and receives response from the server.
|
public MultipartUtility(String requestURL, String charset, Map<String,String> headers) throws IOException
requestURL - the urlcharset - character-set like UTFheaders - header map for the requestIOException - failed to obtain output streampublic void addFormField(String name, String value)
name - field namevalue - field valuepublic void addFilePart(String fieldName, File uploadFile) throws IOException
fieldName - name attribute in the input taguploadFile - a File to be uploadedIOException - on failure to copy filepublic void addHeaderField(String name, String value)
name - - name of the header fieldvalue - - value of the header fieldpublic String finish() throws IOException
IOException - failed to read inout streamCopyright © 2023. All rights reserved.