Class MultipartBody.Builder
java.lang.Object
dev.ua.theroer.magicutils.http.MultipartBody.Builder
- Enclosing class:
MultipartBody
Builder for multipart/form-data content.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOverrides the multipart boundary string.build()Builds the multipart body.Adds a raw byte part with optional content type and filename.Adds a file part with a detected content type.Adds a file part with custom content type and filename.Adds a text field part.
-
Constructor Details
-
Builder
public Builder()Creates a new builder.
-
-
Method Details
-
boundary
Overrides the multipart boundary string.- Parameters:
boundary- boundary value- Returns:
- this builder
-
text
Adds a text field part.- Parameters:
name- field namevalue- field value- Returns:
- this builder
-
file
Adds a file part with a detected content type.- Parameters:
name- field namepath- file path- Returns:
- this builder
- Throws:
IOException- if the file cannot be read
-
file
public MultipartBody.Builder file(String name, Path path, String contentType, String filename) throws IOException Adds a file part with custom content type and filename.- Parameters:
name- field namepath- file pathcontentType- content type or null to auto-detectfilename- file name or null to use the path name- Returns:
- this builder
- Throws:
IOException- if the file cannot be read
-
bytes
Adds a raw byte part with optional content type and filename.- Parameters:
name- field namedata- byte array payloadcontentType- content type or null for defaultfilename- filename or null for default- Returns:
- this builder
-
build
-