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
-
public class FilePart extends PartBase
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
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_CHARSETDefault charset of file attachments.static java.lang.StringDEFAULT_CONTENT_TYPEDefault content encoding of file attachments.static java.lang.StringDEFAULT_TRANSFER_ENCODINGDefault transfer encoding of file attachments.protected static java.lang.StringFILE_NAMEAttachment's file name-
Fields inherited from class org.apache.commons.httpclient.methods.multipart.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
Constructors Constructor Description FilePart(java.lang.String name, java.io.File file)FilePart Constructor.FilePart(java.lang.String name, java.io.File file, java.lang.String contentType, java.lang.String charset)FilePart Constructor.FilePart(java.lang.String name, java.lang.String fileName, java.io.File file)FilePart Constructor.FilePart(java.lang.String name, java.lang.String fileName, java.io.File file, java.lang.String contentType, java.lang.String charset)FilePart Constructor.FilePart(java.lang.String name, PartSource partSource)FilePart Constructor.FilePart(java.lang.String name, PartSource partSource, java.lang.String contentType, java.lang.String charset)FilePart Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PartSourcegetSource()Returns the source of the file part.protected longlengthOfData()Return the length of the data.protected voidsendData(java.io.OutputStream out)Write the data in "source" to the specified stream.protected voidsendDispositionHeader(java.io.OutputStream out)Write the disposition header to the output stream-
Methods inherited from class org.apache.commons.httpclient.methods.multipart.PartBase
getCharSet, getContentType, getName, getTransferEncoding, setCharSet, setContentType, setName, setTransferEncoding
-
Methods inherited from class org.apache.commons.httpclient.methods.multipart.Part
getBoundary, getLengthOfParts, getLengthOfParts, getPartBoundary, isRepeatable, length, send, sendContentTypeHeader, sendEnd, sendEndOfHeader, sendParts, sendParts, sendStart, sendTransferEncodingHeader, toString
-
-
-
-
Field Detail
-
DEFAULT_CONTENT_TYPE
public static final java.lang.String DEFAULT_CONTENT_TYPE
Default content encoding of file attachments.- See Also:
- Constant Field Values
-
DEFAULT_CHARSET
public static final java.lang.String DEFAULT_CHARSET
Default charset of file attachments.- See Also:
- Constant Field Values
-
DEFAULT_TRANSFER_ENCODING
public static final java.lang.String DEFAULT_TRANSFER_ENCODING
Default transfer encoding of file attachments.- See Also:
- Constant Field Values
-
FILE_NAME
protected static final java.lang.String FILE_NAME
Attachment's file name- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FilePart
public FilePart(java.lang.String name, PartSource partSource, java.lang.String contentType, java.lang.String charset)FilePart Constructor.
-
FilePart
public FilePart(java.lang.String name, PartSource partSource)FilePart Constructor.- Parameters:
name- the name for this partpartSource- the source for this part
-
FilePart
public FilePart(java.lang.String name, java.io.File file) throws java.io.FileNotFoundExceptionFilePart Constructor.- Parameters:
name- the name of the file partfile- the file to post- Throws:
java.io.FileNotFoundException- if the file is not a normal file or if it is not readable.
-
FilePart
public FilePart(java.lang.String name, java.io.File file, java.lang.String contentType, java.lang.String charset) throws java.io.FileNotFoundExceptionFilePart 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:
java.io.FileNotFoundException- if the file is not a normal file or if it is not readable.
-
FilePart
public FilePart(java.lang.String name, java.lang.String fileName, java.io.File file) throws java.io.FileNotFoundExceptionFilePart Constructor.- Parameters:
name- the name of the file partfileName- the file namefile- the file to post- Throws:
java.io.FileNotFoundException- if the file is not a normal file or if it is not readable.
-
FilePart
public FilePart(java.lang.String name, java.lang.String fileName, java.io.File file, java.lang.String contentType, java.lang.String charset) throws java.io.FileNotFoundExceptionFilePart 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:
java.io.FileNotFoundException- if the file is not a normal file or if it is not readable.
-
-
Method Detail
-
sendDispositionHeader
protected void sendDispositionHeader(java.io.OutputStream out) throws java.io.IOExceptionWrite the disposition header to the output stream- Overrides:
sendDispositionHeaderin classPart- Parameters:
out- The output stream- Throws:
java.io.IOException- If an IO problem occurs- See Also:
Part.sendDispositionHeader(OutputStream)
-
sendData
protected void sendData(java.io.OutputStream out) throws java.io.IOExceptionWrite the data in "source" to the specified stream.- Specified by:
sendDatain classPart- Parameters:
out- The output stream.- Throws:
java.io.IOException- if an IO problem occurs.- See Also:
Part.sendData(OutputStream)
-
getSource
protected PartSource getSource()
Returns the source of the file part.- Returns:
- The source.
-
lengthOfData
protected long lengthOfData() throws java.io.IOExceptionReturn the length of the data.- Specified by:
lengthOfDatain classPart- Returns:
- The length.
- Throws:
java.io.IOException- if an IO problem occurs- See Also:
Part.lengthOfData()
-
-