public class

FilePart

extends PartBase
java.lang.Object
   ↳ com.ning.http.multipart.Part
     ↳ com.ning.http.multipart.PartBase
       ↳ com.ning.http.multipart.FilePart

Class Overview

This class is an adaptation of the Apache HttpClient implementationhttp://hc.apache.org/httpclient-3.x/

Summary

Constants
String DEFAULT_CHARSET Default charset of file attachments.
String DEFAULT_CONTENT_TYPE Default content encoding of file attachments.
String DEFAULT_TRANSFER_ENCODING Default transfer encoding of file attachments.
String FILE_NAME Attachment's file name
[Expand]
Inherited Constants
From class com.ning.http.multipart.Part
Public Constructors
FilePart(String name, PartSource partSource)
FilePart Constructor.
FilePart(String name, PartSource partSource, String contentType, String charset)
FilePart Constructor.
FilePart(String name, File file)
FilePart Constructor.
FilePart(String name, File file, String contentType, String charset)
FilePart Constructor.
FilePart(String name, String fileName, File file)
FilePart Constructor.
FilePart(String name, String fileName, File file, String contentType, String charset)
FilePart Constructor.
Public Methods
long getStalledTime()
void setStalledTime(long ms)
Protected Methods
PartSource getSource()
Returns the source of the file part.
long lengthOfData()
Return the length of the data.
void sendData(OutputStream out)
Write the data in "source" to the specified stream.
void sendDispositionHeader(OutputStream out)
Write the disposition header to the output stream
[Expand]
Inherited Methods
From class com.ning.http.multipart.PartBase
From class com.ning.http.multipart.Part
From class java.lang.Object
From interface com.ning.http.client.Part

Constants

public static final String DEFAULT_CHARSET

Default charset of file attachments.

Constant Value: "ISO-8859-1"

public static final String DEFAULT_CONTENT_TYPE

Default content encoding of file attachments.

Constant Value: "application/octet-stream"

public static final String DEFAULT_TRANSFER_ENCODING

Default transfer encoding of file attachments.

Constant Value: "binary"

protected static final String FILE_NAME

Attachment's file name

Constant Value: "; filename="

Public Constructors

public FilePart (String name, PartSource partSource)

FilePart Constructor.

Parameters
name the name for this part
partSource the source for this part

public FilePart (String name, PartSource partSource, String contentType, String charset)

FilePart Constructor.

Parameters
name the name for this part
partSource the source for this part
contentType the content type for this part, if null the default is used
charset the charset encoding for this part, if null the default is used

public FilePart (String name, File file)

FilePart Constructor.

Parameters
name the name of the file part
file the file to post
Throws
FileNotFoundException if the file is not a normal file or if it is not readable.

public FilePart (String name, File file, String contentType, String charset)

FilePart Constructor.

Parameters
name the name of the file part
file the file to post
contentType the content type for this part, if null the default is used
charset the charset encoding for this part, if null the default is used
Throws
FileNotFoundException if the file is not a normal file or if it is not readable.

public FilePart (String name, String fileName, File file)

FilePart Constructor.

Parameters
name the name of the file part
fileName the file name
file the file to post
Throws
FileNotFoundException if the file is not a normal file or if it is not readable.

public FilePart (String name, String fileName, File file, String contentType, String charset)

FilePart Constructor.

Parameters
name the name of the file part
fileName the file name
file the file to post
contentType the content type for this part, if null the default is used
charset the charset encoding for this part, if null the default is used
Throws
FileNotFoundException if the file is not a normal file or if it is not readable.

Public Methods

public long getStalledTime ()

public void setStalledTime (long ms)

Protected Methods

protected PartSource getSource ()

Returns the source of the file part.

Returns
  • The source.

protected long lengthOfData ()

Return the length of the data.

Returns
  • The length.
Throws
IOException if an IO problem occurs

protected void sendData (OutputStream out)

Write the data in "source" to the specified stream.

Parameters
out The output stream.
Throws
IOException if an IO problem occurs.

protected void sendDispositionHeader (OutputStream out)

Write the disposition header to the output stream

Parameters
out The output stream
Throws
IOException If an IO problem occurs