Package kong.unirest.core.java
Class MultipartBodyPublisher.Builder
- java.lang.Object
-
- kong.unirest.core.java.MultipartBodyPublisher.Builder
-
- Enclosing class:
- MultipartBodyPublisher
static final class MultipartBodyPublisher.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) MultipartBodyPublisher
build(ProgressMonitor monitor)
Creates and returns a newMultipartBodyPublisher
with a snapshot of the added parts.(package private) MultipartBodyPublisher.Builder
filePart(java.lang.String name, java.nio.file.Path file, java.lang.String mediaType)
Adds a file form field with given name, file and media type.(package private) MultipartBodyPublisher.Builder
formPart(java.lang.String name, java.lang.String filename, java.net.http.HttpRequest.BodyPublisher body)
Adds a form field with the given name, filename and body.(package private) MultipartBodyPublisher.Builder
formPart(java.lang.String name, java.net.http.HttpRequest.BodyPublisher bodyPublisher)
Adds a form field with the given name and body.(package private) MultipartBodyPublisher.Builder
textPart(java.lang.String name, java.lang.Object value)
Adds atext/plain
form field with the given name and value.(package private) MultipartBodyPublisher.Builder
textPart(java.lang.String name, java.lang.Object value, java.nio.charset.Charset charset)
Adds atext/plain
form field with the given name and value using the given charset for encoding the field's body.
-
-
-
Field Detail
-
parts
private final java.util.List<Part> parts
-
-
Method Detail
-
formPart
MultipartBodyPublisher.Builder formPart(java.lang.String name, java.net.http.HttpRequest.BodyPublisher bodyPublisher)
Adds a form field with the given name and body.- Parameters:
name
- the field's namebodyPublisher
- the field's body publisher
-
formPart
MultipartBodyPublisher.Builder formPart(java.lang.String name, java.lang.String filename, java.net.http.HttpRequest.BodyPublisher body)
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
MultipartBodyPublisher.Builder textPart(java.lang.String name, java.lang.Object value)
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(java.lang.String name, java.lang.Object value, java.nio.charset.Charset charset)
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(java.lang.String name, java.nio.file.Path file, java.lang.String mediaType) throws java.io.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:
java.io.FileNotFoundException
- if a file with the given path cannot be found
-
build
MultipartBodyPublisher build(ProgressMonitor monitor)
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:
java.lang.IllegalStateException
- if no part was added
-
-