HttpMultipartPost
public
class
HttpMultipartPost
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.net.HttpMultipartPost
|
Helper class for making multipart HTTP post requests. This class is used to upload files
using multipart HTTP post (RFC 2388).
To send multipart posts create this object passing it the url to send the requests to.
Then set necessary parameters using the addParameter method and specify a file to upload
using addFile method. After everything is set, send the request using the send method.
Currently the implementation only supports 'text/plain' content types.
Summary
Public methods |
void
|
addParameter(String name, String value)
Adds a string parameter to the request.
|
void
|
addTextFile(String name, String fileName, InputStream in)
Add a file parameter to the request.
|
void
|
addTextFile(String name, File file)
Add a file parameter to the request.
|
void
|
send()
Sends the request to the server.
|
Public constructors
HttpMultipartPost
public HttpMultipartPost (String url)
HttpMultipartPost
public HttpMultipartPost (String url,
IHttpHelper httpHelper)
Parameters |
url |
String |
httpHelper |
IHttpHelper |
Public methods
addParameter
public void addParameter (String name,
String value)
Adds a string parameter to the request.
Parameters |
name |
String : name of the parameter. |
value |
String : value of the parameter. |
addTextFile
public void addTextFile (String name,
String fileName,
InputStream in)
Add a file parameter to the request. The contents of the file to upload
will come from reading the input stream. Currently the implementation only
supports 'text/plain' content type.
Parameters |
name |
String : name of the parameter. |
fileName |
String : file name to report for the data in the stream. |
in |
InputStream : stream whose contents are being uploaded. |
addTextFile
public void addTextFile (String name,
File file)
Add a file parameter to the request. Opens the file, reads its contents
and sends them as part of the request. Currently the implementation
only supports 'text/plain' content type.
Parameters |
name |
String : name of the parameter. |
file |
File : file whose contents will be uploaded as part of the request. |
send
public void send ()
Sends the request to the server.