@Deprecated public class MultipartPoster extends Object
This class allows posting a multipart/form-data request to a server. It uses an URL as the base to connect to, and it has methods to add parameters and files to the set to send.
This class uses a lazy mechanism to get file data to write for posted files: when data is required for a file parameter it repeatedly calls a handler for a given parameter.
First create an instance of this class. Then add all parameters to PUT using the addParam() and addFile() calls. When all parameters to put have been set then call issue() to exchange the request.
The call to issue returns the connection that is used to send the request; you need to read the response stream yourself (by calling getInputStream() and reading it) since I have NO idea what you want to do with the answer ;-)
This structure can be reused by calling clear() before use, which clears all parameters and files set.
| Constructor and Description |
|---|
MultipartPoster()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFile(String name,
String fname,
File f)
Deprecated.
Adds a file parameter to the request.
|
void |
addFile(String name,
String fname,
InputStream is,
int len)
Deprecated.
Adds a file to send to the request.
|
void |
addFile(String name,
String fname,
MultipartFile mf)
Deprecated.
Adds a file parameter to the request.
|
void |
addParam(String name,
String value)
Deprecated.
Adds a parameter to send to the http server.
|
void |
clear()
Deprecated.
Removes all parameters currently in the table.
|
void |
clearProxyAuthentication()
Deprecated.
|
HttpURLConnection |
exchange(URL url)
Deprecated.
Sends the constructed request to the server, and returns the reply
stream (the output file generated by the server).
|
void |
setListener(MultipartSendListener mpsl)
Deprecated.
|
void |
setProxyAuthentication(String auth)
Deprecated.
|
void |
setProxyAuthentication(String uid,
String pw)
Deprecated.
|
public void setProxyAuthentication(String auth)
public void clearProxyAuthentication()
public void setListener(MultipartSendListener mpsl)
public void clear()
public void addParam(String name, String value)
name - the parameter's namevalue - the parameter's value.public void addFile(String name, String fname, MultipartFile mf)
name - the parameter's name.fname - the suggested filenamemf - the handler which will provide the file's data as soon as it
is needed.public void addFile(String name, String fname, File f)
name - the name of the parameterfname - the suggested filenamef - the existing file to sendpublic void addFile(String name, String fname, InputStream is, int len)
name - the name of the parameter.fname - the suggested filenameis - the stream providing the data.public HttpURLConnection exchange(URL url) throws Exception
conn - the URL to post the data to,Exception - on any error.Copyright © 2017 etc.to. All rights reserved.