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(java.lang.String boundary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) MultipartBodyPublisherbuild(ProgressMonitor monitor)Creates and returns a newMultipartBodyPublisherwith a snapshot of the added parts.(package private) MultipartBodyPublisher.BuilderfilePart(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.BuilderformPart(java.lang.String name, java.lang.String filename, java.net.http.HttpRequest.BodyPublisher body, java.lang.String contentType)Adds a form field with the given name, filename and body.(package private) MultipartBodyPublisher.BuilderformPart(java.lang.String name, java.net.http.HttpRequest.BodyPublisher bodyPublisher, java.lang.String contentType)Adds a form field with the given name and body.(package private) MultipartBodyPublisher.BuildertextPart(java.lang.String name, java.lang.Object value, java.lang.String contentType)Adds atext/plainform field with the given name and value.(package private) MultipartBodyPublisher.BuildertextPart(java.lang.String name, java.lang.Object value, java.nio.charset.Charset charset, java.lang.String contentType)Adds atext/plainform 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
-
boundary
private final java.lang.String boundary
-
-
Method Detail
-
formPart
MultipartBodyPublisher.Builder formPart(java.lang.String name, java.net.http.HttpRequest.BodyPublisher bodyPublisher, java.lang.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(java.lang.String name, java.lang.String filename, java.net.http.HttpRequest.BodyPublisher body, java.lang.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
MultipartBodyPublisher.Builder textPart(java.lang.String name, java.lang.Object value, java.lang.String contentType)
Adds atext/plainform field with the given name and value.UTF-8is 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, java.lang.String contentType)
Adds atext/plainform 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 newMultipartBodyPublisherwith 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
-
-