Class MultipartFormWriter

  • All Implemented Interfaces:
    AutoCloseable

    public class MultipartFormWriter
    extends Object
    implements AutoCloseable
    Represents a form writer capable of sending files and form data as multipart chunks.
    • Constructor Detail

      • MultipartFormWriter

        public MultipartFormWriter​(MultipartFormContentType contentType,
                                   OutputStream os)
        Attaches to the outputstream and allows writing form data or files to it.
        Parameters:
        contentType - The form content type
        os - the output stream
    • Method Detail

      • writeField

        public void writeField​(String name,
                               String value)
                        throws IOException
        Writes a string field value.
        Parameters:
        name - the field name (required)
        value - the field value
        Throws:
        IOException - on input/output errors
      • writeFile

        public void writeFile​(String name,
                              File file)
                       throws IOException
        Writes a file's contents.
        Parameters:
        name - the field name
        file - the file (the file must exist)
        Throws:
        IOException - on input/output errors
      • writeFile

        public void writeFile​(String name,
                              File file,
                              String mimeType)
                       throws IOException
        Writes a input stream's contents.
        Parameters:
        name - the field name
        file - the file
        mimeType - The file content type
        Throws:
        IOException - on input/output errors