Class MultipartFormWriter
- java.lang.Object
-
- org.codehaus.cargo.container.internal.http.writer.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 Summary
Constructors Constructor Description MultipartFormWriter(MultipartFormContentType contentType, OutputStream os)
Attaches to the outputstream and allows writing form data or files to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
writeField(String name, String value)
Writes a string field value.void
writeFile(String name, File file)
Writes a file's contents.void
writeFile(String name, File file, String mimeType)
Writes a input stream's contents.
-
-
-
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 typeos
- 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 namefile
- 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 namefile
- the filemimeType
- The file content type- Throws:
IOException
- on input/output errors
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
-