to top
public class

HttpMultipartPost

extends Object
java.lang.Object
   ↳ com.android.tradefed.util.net.HttpMultipartPost

Class Overview

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 Constructors
HttpMultipartPost(String url, IHttpHelper httpHelper)
HttpMultipartPost(String url)
Public Methods
void addParameter(String name, String value)
Adds a string parameter to the request.
void addTextFile(String name, File file)
Add a file parameter to the request.
void addTextFile(String name, String fileName, InputStream in)
Add a file parameter to the request.
void send()
Sends the request to the server.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public HttpMultipartPost (String url, IHttpHelper httpHelper)

public HttpMultipartPost (String url)

Public Methods

public void addParameter (String name, String value)

Adds a string parameter to the request.

Parameters
name name of the parameter.
value value of the parameter.
Throws
IOException

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 name of the parameter.
file file whose contents will be uploaded as part of the request.
Throws
IOException

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 name of the parameter.
fileName file name to report for the data in the stream.
in stream whose contents are being uploaded.
Throws
IOException

public void send ()

Sends the request to the server.

Throws
IOException
IHttpHelper.DataSizeException
IOException