Class MultipartBody.Builder

java.lang.Object
org.apache.juneau.http.entity.MultipartBody.Builder
Enclosing class:
MultipartBody

public static final class MultipartBody.Builder extends Object
Fluent builder for MultipartBody.
Since:
9.2.1
  • Method Details

    • boundary

      Sets a custom multipart boundary string (defaults to a random UUID-derived value).
      Parameters:
      value - The boundary. Must not be null or blank.
      Returns:
      This object.
    • field

      public MultipartBody.Builder field(String name, String value)
      Adds a plain-text form field.
      Parameters:
      name - The field name. Must not be null.
      value - The field value. Must not be null.
      Returns:
      This object.
    • file

      public MultipartBody.Builder file(String name, File file, String contentType)
      Adds a file upload part.
      Parameters:
      name - The field name. Must not be null.
      file - The file to upload. Must not be null.
      contentType - The MIME content type for the file. May be null.
      Returns:
      This object.
    • part

      Adds a custom part.
      Parameters:
      part - The part to add. Must not be null.
      Returns:
      This object.
    • build

      public MultipartBody build()
      Builds and returns the MultipartBody.
      Returns:
      A new instance. Never null.