Class HttpRequestMultiPart

java.lang.Object
kong.unirest.core.BaseRequest<MultipartBody>
kong.unirest.core.HttpRequestMultiPart
All Implemented Interfaces:
Body, HttpRequest<MultipartBody>, MultipartBody

class HttpRequestMultiPart extends BaseRequest<MultipartBody> implements MultipartBody
  • Field Details

  • Constructor Details

  • Method Details

    • field

      public MultipartBody field(String name, String value)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      value - : The string value for the field
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, String value, String contentType)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      value - : The string value for the field
      contentType - : the content type of the value
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, String value, ContentType contentType)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      value - : The string value for the field
      contentType - : the content type of the value
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, Collection<?> collection)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      collection - : A collection of values for the same name.
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, InputStream value, ContentType contentType)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      value - : A input stream
      contentType - : the content mime-type of the file
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, File file)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      file - : A File object.
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, File file, String contentType)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      file - : A File object.
      contentType - : the content mime-type of the file
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, InputStream stream, ContentType contentType, String fileName)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      stream - : A input stream
      contentType - : the content mime-type of the file
      fileName - : the name of the file which will be included in the file part header
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, InputStream stream, String fileName)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      stream - : The raw bytes for the file
      fileName - : the name of the file which will be included in the file part header
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, byte[] bytes, ContentType contentType, String fileName)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      bytes - : The raw bytes for the file
      contentType - : the content mime-type of the file
      fileName - : the name of the file which will be included in the file part header
      Returns:
      The same MultipartBody
    • field

      public MultipartBody field(String name, byte[] bytes, String fileName)
      Description copied from interface: MultipartBody
      add a simple field with a name and value
      Specified by:
      field in interface MultipartBody
      Parameters:
      name - : the Name of the form field
      bytes - : The raw bytes for the file
      fileName - : the name of the file which will be included in the file part header
      Returns:
      The same MultipartBody
    • charset

      public MultipartBody charset(Charset charset)
      Description copied from interface: MultipartBody
      Set the encoding of the request body
      Specified by:
      charset in interface MultipartBody
      Parameters:
      charset - the character set encoding of the body
      Returns:
      The same MultipartBody
    • contentType

      public MultipartBody contentType(String mimeType)
      Description copied from interface: MultipartBody
      Set the mime-type of the request body
      Specified by:
      contentType in interface MultipartBody
      Parameters:
      mimeType - the mime type of the body
      Returns:
      The same MultipartBody
    • mode

      public MultipartBody mode(MultipartMode value)
      Description copied from interface: MultipartBody
      Set the Apache Mode.
      Specified by:
      mode in interface MultipartBody
      Parameters:
      value - the value of the mode
      Returns:
      The same MultipartBody
    • uploadMonitor

      public MultipartBody uploadMonitor(ProgressMonitor uploadMonitor)
      Description copied from interface: MultipartBody
      Set a file Progress upload monitor suitable for drawing progress bars and whatnot.
      Specified by:
      uploadMonitor in interface MultipartBody
      Parameters:
      uploadMonitor - a monitor
      Returns:
      The same MultipartBody
    • boundary

      public MultipartBody boundary(String boundaryIdentifier)
      Description copied from interface: MultipartBody
      Sets the value to use as the boundary identifier. see https://datatracker.ietf.org/doc/html/rfc2046
      Specified by:
      boundary in interface MultipartBody
      Parameters:
      boundaryIdentifier - the value
      Returns:
      The same MultipartBody
    • getBoundary

      public String getBoundary()
      Specified by:
      getBoundary in interface Body
    • getCharset

      public Charset getCharset()
      Specified by:
      getCharset in interface Body
    • fields

      public MultipartBody fields(Map<String,Object> fields)
    • field

      public MultipartBody field(String name, Object value, String contentType)
    • addPart

      private void addPart(String name, Object value, String contentType)
    • addPart

      private void addPart(BodyPart value)
    • getBody

      public Optional<Body> getBody()
      Specified by:
      getBody in interface HttpRequest<MultipartBody>
      Returns:
      if the request has a body it will be here.
    • isMultiPart

      public boolean isMultiPart()
      Specified by:
      isMultiPart in interface Body
    • isEntityBody

      public boolean isEntityBody()
      Specified by:
      isEntityBody in interface Body
    • multiParts

      public Collection<BodyPart> multiParts()
      Specified by:
      multiParts in interface Body
    • getMode

      public MultipartMode getMode()
      Specified by:
      getMode in interface Body
    • getMonitor

      public ProgressMonitor getMonitor()
      Specified by:
      getMonitor in interface Body
    • forceMultiPart

      MultipartBody forceMultiPart(boolean value)