Class FilePart
java.lang.Object
org.apache.commons.httpclient.methods.multipart.Part
org.apache.commons.httpclient.methods.multipart.PartBase
org.apache.commons.httpclient.methods.multipart.FilePart
This class implements a part of a Multipart post object that
consists of a file.
- Since:
- 2.0
- Author:
- Matthew Albright, Jeff Dever, Adrian Sutton, Michael Becke, Mark Diggory, Mike Bowler, Oleg Kalnichevski
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault charset of file attachments.static final StringDefault content encoding of file attachments.static final StringDefault transfer encoding of file attachments.protected static final StringAttachment's file nameFields inherited from class Part
BOUNDARY, BOUNDARY_BYTES, CHARSET, CHARSET_BYTES, CONTENT_DISPOSITION, CONTENT_DISPOSITION_BYTES, CONTENT_TRANSFER_ENCODING, CONTENT_TRANSFER_ENCODING_BYTES, CONTENT_TYPE, CONTENT_TYPE_BYTES, CRLF, CRLF_BYTES, EXTRA, EXTRA_BYTES, QUOTE, QUOTE_BYTES -
Constructor Summary
ConstructorsConstructorDescriptionFilePart Constructor.FilePart Constructor.FilePart Constructor.FilePart Constructor.FilePart(String name, PartSource partSource) FilePart Constructor.FilePart(String name, PartSource partSource, String contentType, String charset) FilePart Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected PartSourceReturns the source of the file part.protected longReturn the length of the data.protected voidsendData(OutputStream out) Write the data in "source" to the specified stream.protected voidWrite the disposition header to the output streamMethods inherited from class PartBase
getCharSet, getContentType, getName, getTransferEncoding, setCharSet, setContentType, setName, setTransferEncodingMethods inherited from class Part
getBoundary, getLengthOfParts, getLengthOfParts, getPartBoundary, isRepeatable, length, send, sendContentTypeHeader, sendEnd, sendEndOfHeader, sendParts, sendParts, sendStart, sendTransferEncodingHeader, toString
-
Field Details
-
DEFAULT_CONTENT_TYPE
Default content encoding of file attachments.- See Also:
-
DEFAULT_CHARSET
-
DEFAULT_TRANSFER_ENCODING
Default transfer encoding of file attachments.- See Also:
-
FILE_NAME
-
-
Constructor Details
-
FilePart
FilePart Constructor. -
FilePart
FilePart Constructor.- Parameters:
name- the name for this partpartSource- the source for this part
-
FilePart
FilePart Constructor.- Parameters:
name- the name of the file partfile- the file to post- Throws:
FileNotFoundException- if the file is not a normal file or if it is not readable.
-
FilePart
public FilePart(String name, File file, String contentType, String charset) throws FileNotFoundException FilePart Constructor.- Parameters:
name- the name of the file partfile- the file to postcontentType- the content type for this part, ifnullthedefaultis usedcharset- the charset encoding for this part, ifnullthedefaultis used- Throws:
FileNotFoundException- if the file is not a normal file or if it is not readable.
-
FilePart
FilePart Constructor.- Parameters:
name- the name of the file partfileName- the file namefile- the file to post- Throws:
FileNotFoundException- if the file is not a normal file or if it is not readable.
-
FilePart
public FilePart(String name, String fileName, File file, String contentType, String charset) throws FileNotFoundException FilePart Constructor.- Parameters:
name- the name of the file partfileName- the file namefile- the file to postcontentType- the content type for this part, ifnullthedefaultis usedcharset- the charset encoding for this part, ifnullthedefaultis used- Throws:
FileNotFoundException- if the file is not a normal file or if it is not readable.
-
-
Method Details
-
sendDispositionHeader
Write the disposition header to the output stream- Overrides:
sendDispositionHeaderin classPart- Parameters:
out- The output stream- Throws:
IOException- If an IO problem occurs- See Also:
-
sendData
Write the data in "source" to the specified stream.- Specified by:
sendDatain classPart- Parameters:
out- The output stream.- Throws:
IOException- if an IO problem occurs.- See Also:
-
getSource
-
lengthOfData
Return the length of the data.- Specified by:
lengthOfDatain classPart- Returns:
- The length.
- Throws:
IOException- if an IO problem occurs- See Also:
-