Class MultipartBody.Builder

java.lang.Object
io.micronaut.http.client.multipart.MultipartBody.Builder
Enclosing class:
MultipartBody

public static final class MultipartBody.Builder extends Object
A builder class to add different Part to MultipartBody.
  • Method Details

    • addPart

      public MultipartBody.Builder addPart(String name, File file)
      Add a file object to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      file - The file object to copy the content to FileUpload
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String filename, File file)
      Add a file object to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      filename - Name of the file
      file - The file object to copy the content to FileUpload
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String filename, MediaType contentType, File file)
      Add a file object to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      filename - Name of the file
      contentType - File content of type MediaType, possible values could be "text/plain", "application/json" etc
      file - The file object to copy the content to FileUpload
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String filename, byte[] data)
      Add bytes data to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      filename - Name of the file
      data - A byte Array (byte[]) representing the contents of the file
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String filename, MediaType contentType, byte[] data)
      Add bytes data to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      filename - Name of the file
      contentType - The content type of File, possible values could be "text/plain", "application/json" etc
      data - A byte Array (byte[]) representing the contents of the file
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String filename, InputStream data, long contentLength)
      Add a InputStream data to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      filename - Name of the file
      data - An InputStream data value representing the content of file object
      contentLength - The size of the content
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String filename, MediaType contentType, InputStream data, long contentLength)
      Add a InputStream data to MultipartBody.
      Parameters:
      name - Name of the parameter for file object to be passed in multipart request
      filename - Name of the file
      contentType - The content type of File, possible values could be "text/plain", "application/json" etc
      data - An InputStream data value representing the content of file object
      contentLength - The size of the content
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • addPart

      public MultipartBody.Builder addPart(String name, String value)
      Add a file object to MultipartBody.
      Parameters:
      name - Name of the parameter or the key to be passed in multipart request
      value - Plain String value for the parameter
      Returns:
      A MultipartBody.Builder to build MultipartBody
    • build

      public MultipartBody build() throws MultipartException
      Creates MultipartBody from the provided parts.
      Returns:
      The MultipartBody
      Throws:
      MultipartException - If there are no parts