Class MultiPartContentProvider

java.lang.Object
org.eclipse.jetty.client.util.AbstractTypedContentProvider
org.eclipse.jetty.client.util.MultiPartContentProvider
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ByteBuffer>, ContentProvider, ContentProvider.Typed, AsyncContentProvider

@Deprecated public class MultiPartContentProvider extends AbstractTypedContentProvider implements AsyncContentProvider, Closeable
Deprecated.

A ContentProvider for form uploads with the "multipart/form-data" content type.

Example usage:

 MultiPartContentProvider multiPart = new MultiPartContentProvider();
 multiPart.addFieldPart("field", new StringContentProvider("foo"), null);
 multiPart.addFilePart("icon", "img.png", new PathContentProvider(Paths.get("/tmp/img.png")), null);
 multiPart.close();
 ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
         .method(HttpMethod.POST)
         .content(multiPart)
         .send();
 

The above example would be the equivalent of submitting this form:

 <form method="POST" enctype="multipart/form-data"  accept-charset="UTF-8">
     <input type="text" name="field" value="foo" />
     <input type="file" name="icon" />
 </form>
 
  • Constructor Details

    • MultiPartContentProvider

      public MultiPartContentProvider()
      Deprecated.
    • MultiPartContentProvider

      public MultiPartContentProvider(String boundary)
      Deprecated.
  • Method Details

    • addFieldPart

      public void addFieldPart(String name, ContentProvider content, HttpFields fields)
      Deprecated.

      Adds a field part with the given name as field name, and the given content as part content.

      The Content-Type of this part will be obtained from:

      Parameters:
      name - the part name
      content - the part content
      fields - the headers associated with this part
    • addFilePart

      public void addFilePart(String name, String fileName, ContentProvider content, HttpFields fields)
      Deprecated.

      Adds a file part with the given name as field name, the given fileName as file name, and the given content as part content.

      The Content-Type of this part will be obtained from:

      Parameters:
      name - the part name
      fileName - the file name associated to this part
      content - the part content
      fields - the headers associated with this part
    • setListener

      public void setListener(AsyncContentProvider.Listener listener)
      Deprecated.
      Specified by:
      setListener in interface AsyncContentProvider
      Parameters:
      listener - the listener to be notified of content availability
    • getLength

      public long getLength()
      Deprecated.
      Specified by:
      getLength in interface ContentProvider
      Returns:
      the content length, if known, or -1 if the content length is unknown
    • iterator

      public Iterator<ByteBuffer> iterator()
      Deprecated.
      Specified by:
      iterator in interface Iterable<ByteBuffer>
    • close

      public void close()
      Deprecated.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable