Package com.oorian.apis
Class MultipartRequest
java.lang.Object
com.oorian.apis.ApiHttpRequest
com.oorian.apis.MultipartRequest
- Direct Known Subclasses:
MultipartPostRequest,MultipartPutRequest
Abstract base class for multipart HTTP requests that support form parameters and file uploads.
Builds multipart/form-data request bodies with automatically generated boundary strings. Subclasses specify the HTTP method (POST or PUT).
-
Field Summary
Fields inherited from class com.oorian.apis.ApiHttpRequest
DELETE, GET, POST, PUT -
Constructor Summary
ConstructorsConstructorDescriptionMultipartRequest(int method, String url) Creates a new multipart request with the specified HTTP method and URL. -
Method Summary
Modifier and TypeMethodDescriptionAdds a file to this multipart request.Adds a file to this multipart request with a specified form field name.addFile(String fileName, FileInputStream fileInputStream) Adds a file to this multipart request from an input stream.addFile(String paramName, String fileName, FileInputStream fileInputStream) Adds a file to this multipart request from an input stream with a specified form field name.addParameter(String name, String value) Adds a form parameter to this multipart request.protected HttpRequest.BodyPublishergetData()Methods inherited from class com.oorian.apis.ApiHttpRequest
addHeader, addHeaders, getCharset, getHeaders, getResponse, getUrl, getUrlConnection, send, send, setCharset, setConnectTimeout, setContentType, setReadTimeout, setUrl
-
Constructor Details
-
MultipartRequest
Creates a new multipart request with the specified HTTP method and URL.- Parameters:
method- the HTTP method constant.url- the target URL.
-
-
Method Details
-
addParameter
Adds a form parameter to this multipart request.- Parameters:
name- the parameter name.value- the parameter value.- Returns:
- the created request parameter.
-
addFile
Adds a file to this multipart request with a specified form field name.- Parameters:
paramName- the form field name.file- the file to upload.- Returns:
- the created file parameter.
- Throws:
FileNotFoundException- if the file does not exist.
-
addFile
Adds a file to this multipart request.- Parameters:
file- the file to upload.- Returns:
- the created file parameter.
- Throws:
FileNotFoundException- if the file does not exist.
-
addFile
Adds a file to this multipart request from an input stream with a specified form field name.- Parameters:
paramName- the form field name.fileName- the file name.fileInputStream- the input stream containing the file data.- Returns:
- the created file parameter.
-
addFile
Adds a file to this multipart request from an input stream.- Parameters:
fileName- the file name.fileInputStream- the input stream containing the file data.- Returns:
- the created file parameter.
-
getData
- Specified by:
getDatain classApiHttpRequest- Throws:
HttpRequestException
-