Class MultipartBody.Builder
java.lang.Object
cloud.opencode.base.web.body.MultipartBody.Builder
- Enclosing class:
MultipartBody
Builder for MultipartBody
MultipartBody 构建器
- Since:
- JDK 25, opencode-base-web V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdds a text field.Adds a file with explicit content type and byte data.addFile(String name, String fileName, String contentType, InputStream stream) Adds a file from an InputStream.Adds a file from a Path with automatic content type detection.build()Builds the MultipartBody.
-
Method Details
-
addField
Adds a text field. 添加文本字段。- Parameters:
name- the field name | 字段名value- the field value | 字段值- Returns:
- this builder | 此构建器
-
addFile
Adds a file with explicit content type and byte data. 添加指定内容类型和字节数据的文件。- Parameters:
name- the field name | 字段名fileName- the file name | 文件名contentType- the content type | 内容类型data- the file data | 文件数据- Returns:
- this builder | 此构建器
-
addFile
Adds a file from a Path with automatic content type detection. 从 Path 添加文件,自动检测内容类型。- Parameters:
name- the field name | 字段名file- the file path | 文件路径- Returns:
- this builder | 此构建器
- Throws:
UncheckedIOException- if the file cannot be read | 如果文件无法读取
-
addFile
public MultipartBody.Builder addFile(String name, String fileName, String contentType, InputStream stream) Adds a file from an InputStream. 从 InputStream 添加文件。- Parameters:
name- the field name | 字段名fileName- the file name | 文件名contentType- the content type | 内容类型stream- the input stream | 输入流- Returns:
- this builder | 此构建器
- Throws:
UncheckedIOException- if the stream cannot be read | 如果流无法读取
-
build
Builds the MultipartBody. 构建 MultipartBody。- Returns:
- the multipart body | multipart 请求体
-