Package nxt.util
Class MultipartUtility
- java.lang.Object
-
- nxt.util.MultipartUtility
-
public class MultipartUtility extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MultipartUtility(java.net.URL url, java.nio.charset.Charset charset)
This constructor initializes a new HTTP POST request with content type is set to multipart/form-data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFilePart(java.lang.String fieldName, java.lang.String fileName, byte[] data)
Adds a upload file section to the requestvoid
addFormField(java.lang.String name, java.lang.String value)
Adds a form field to the requestvoid
addHeaderField(java.lang.String name, java.lang.String value)
Adds a header field to the request.java.io.InputStream
finish()
Completes the request and receives response from the server.
-
-
-
Method Detail
-
addFormField
public void addFormField(java.lang.String name, java.lang.String value)
Adds a form field to the request- Parameters:
name
- field namevalue
- field value
-
addFilePart
public void addFilePart(java.lang.String fieldName, java.lang.String fileName, byte[] data)
Adds a upload file section to the request- Parameters:
fieldName
- name attribute in <input type="file" name="..." />fileName
- name of filedata
- file bytes
-
addHeaderField
public void addHeaderField(java.lang.String name, java.lang.String value)
Adds a header field to the request. Unused for now.- Parameters:
name
- - name of the header fieldvalue
- - value of the header field
-
finish
public java.io.InputStream 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.
-
-