Class MultipartBody.Builder

  • Enclosing class:
    MultipartBody

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MultipartBody.Builder addPart​(java.lang.String name, java.io.File file)
      Add a file object to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String value)
      Add a file object to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String filename, byte[] data)
      Add bytes data to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String filename, io.micronaut.http.MediaType contentType, byte[] data)
      Add bytes data to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String filename, io.micronaut.http.MediaType contentType, java.io.File file)
      Add a file object to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String filename, io.micronaut.http.MediaType contentType, java.io.InputStream data, long contentLength)
      Add a InputStream data to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String filename, java.io.File file)
      Add a file object to MultipartBody.
      MultipartBody.Builder addPart​(java.lang.String name, java.lang.String filename, java.io.InputStream data, long contentLength)
      Add a InputStream data to MultipartBody.
      MultipartBody build()
      Creates MultipartBody from the provided parts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • addPart

        public MultipartBody.Builder addPart​(java.lang.String name,
                                             java.io.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​(java.lang.String name,
                                             java.lang.String filename,
                                             java.io.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​(java.lang.String name,
                                             java.lang.String filename,
                                             io.micronaut.http.MediaType contentType,
                                             java.io.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​(java.lang.String name,
                                             java.lang.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​(java.lang.String name,
                                             java.lang.String filename,
                                             io.micronaut.http.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​(java.lang.String name,
                                             java.lang.String filename,
                                             java.io.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​(java.lang.String name,
                                             java.lang.String filename,
                                             io.micronaut.http.MediaType contentType,
                                             java.io.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​(java.lang.String name,
                                             java.lang.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 io.micronaut.http.multipart.MultipartException
        Creates MultipartBody from the provided parts.
        Returns:
        The MultipartBody
        Throws:
        io.micronaut.http.multipart.MultipartException - If there are no parts