Package kong.unirest.core.java
Class MultipartBodyPublisher.Builder
java.lang.Object
kong.unirest.core.java.MultipartBodyPublisher.Builder
- Enclosing class:
MultipartBodyPublisher
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) MultipartBodyPublisher
build
(ProgressMonitor monitor) Creates and returns a newMultipartBodyPublisher
with a snapshot of the added parts.(package private) MultipartBodyPublisher.Builder
Adds a file form field with given name, file and media type.(package private) MultipartBodyPublisher.Builder
formPart
(String name, String filename, HttpRequest.BodyPublisher body, String contentType) Adds a form field with the given name, filename and body.(package private) MultipartBodyPublisher.Builder
formPart
(String name, HttpRequest.BodyPublisher bodyPublisher, String contentType) Adds a form field with the given name and body.(package private) MultipartBodyPublisher.Builder
Adds atext/plain
form field with the given name and value.(package private) MultipartBodyPublisher.Builder
Adds atext/plain
form field with the given name and value using the given charset for encoding the field's body.
-
Field Details
-
parts
-
boundary
-
-
Constructor Details
-
Builder
Builder(String boundary)
-
-
Method Details
-
formPart
MultipartBodyPublisher.Builder formPart(String name, HttpRequest.BodyPublisher bodyPublisher, String contentType) Adds a form field with the given name and body.- Parameters:
name
- the field's namebodyPublisher
- the field's body publishercontentType
- the content type for the part
-
formPart
MultipartBodyPublisher.Builder formPart(String name, String filename, HttpRequest.BodyPublisher body, String contentType) Adds a form field with the given name, filename and body.- Parameters:
name
- the field's namefilename
- the field's filenamebody
- the field's body publisher
-
textPart
Adds atext/plain
form field with the given name and value.UTF-8
is used for encoding the field's body.- Parameters:
name
- the field's namevalue
- an object whose string representation is used as the value
-
textPart
MultipartBodyPublisher.Builder textPart(String name, Object value, Charset charset, String contentType) Adds atext/plain
form field with the given name and value using the given charset for encoding the field's body.- Parameters:
name
- the field's namevalue
- an object whose string representation is used as the valuecharset
- the charset for encoding the field's body
-
filePart
MultipartBodyPublisher.Builder filePart(String name, Path file, String mediaType) throws FileNotFoundException Adds a file form field with given name, file and media type. The field's filename property will be that of the given path'sfilename compontent
.- Parameters:
name
- the field's namefile
- the file's pathmediaType
- the part's media type- Throws:
FileNotFoundException
- if a file with the given path cannot be found
-
build
Creates and returns a newMultipartBodyPublisher
with a snapshot of the added parts. If no boundary was previously set, a randomly generated one is used.- Throws:
IllegalStateException
- if no part was added
-