Class MultipartUtility
- java.lang.Object
-
- com.github.stormbit.sdk.utils.web.MultipartUtility
-
-
Constructor Summary
Constructors Constructor Description MultipartUtility(String requestURL)This constructor initializes a new HTTP POST request with content type is set to multipart/form-data
-
Method Summary
Modifier and Type Method Description voidaddBytesPart(String fieldName, String fileName, byte[] bytes)Adds a upload file section to the requestvoidaddFilePart(String fieldName, File uploadFile)Adds a upload file section to the requestStringfinish()Completes the request and receives response from the server.
-
-
-
Constructor Detail
-
MultipartUtility
public MultipartUtility(String requestURL)
This constructor initializes a new HTTP POST request with content type is set to multipart/form-data- Parameters:
requestURL- request link
-
-
Method Detail
-
addFilePart
public void addFilePart(String fieldName, File uploadFile)
Adds a upload file section to the request- Parameters:
fieldName- name of field in body of POST-requestuploadFile- a File to be uploaded
-
addBytesPart
public void addBytesPart(String fieldName, String fileName, byte[] bytes)
Adds a upload file section to the request- Parameters:
fieldName- name of field in body of POST-requestfileName- filenamebytes- an array of bytes to be uploaded
-
finish
public String 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.
-
-