Class MultipartBody.Builder

java.lang.Object
cloud.opencode.base.web.body.MultipartBody.Builder
Enclosing class:
MultipartBody

public static final class MultipartBody.Builder extends Object
Builder for MultipartBody MultipartBody 构建器
Since:
JDK 25, opencode-base-web V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • addField

      public MultipartBody.Builder addField(String name, String value)
      Adds a text field. 添加文本字段。
      Parameters:
      name - the field name | 字段名
      value - the field value | 字段值
      Returns:
      this builder | 此构建器
    • addFile

      public MultipartBody.Builder addFile(String name, String fileName, String contentType, byte[] data)
      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

      public MultipartBody.Builder addFile(String name, Path file)
      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

      public MultipartBody build()
      Builds the MultipartBody. 构建 MultipartBody。
      Returns:
      the multipart body | multipart 请求体