|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectto.etc.net.MultipartPoster
@Deprecated public class MultipartPoster
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 Summary | |
---|---|
MultipartPoster()
Deprecated. |
Method Summary | |
---|---|
void |
addFile(java.lang.String name,
java.lang.String fname,
java.io.File f)
Deprecated. Adds a file parameter to the request. |
void |
addFile(java.lang.String name,
java.lang.String fname,
java.io.InputStream is,
int len)
Deprecated. Adds a file to send to the request. |
void |
addFile(java.lang.String name,
java.lang.String fname,
MultipartFile mf)
Deprecated. Adds a file parameter to the request. |
void |
addParam(java.lang.String name,
java.lang.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. |
java.net.HttpURLConnection |
exchange(java.net.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(java.lang.String auth)
Deprecated. |
void |
setProxyAuthentication(java.lang.String uid,
java.lang.String pw)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultipartPoster()
Method Detail |
---|
public void setProxyAuthentication(java.lang.String auth)
public void setProxyAuthentication(java.lang.String uid, java.lang.String pw)
public void clearProxyAuthentication()
public void setListener(MultipartSendListener mpsl)
public void clear()
public void addParam(java.lang.String name, java.lang.String value)
name
- the parameter's namevalue
- the parameter's value.public void addFile(java.lang.String name, java.lang.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(java.lang.String name, java.lang.String fname, java.io.File f)
name
- the name of the parameterfname
- the suggested filenamef
- the existing file to sendpublic void addFile(java.lang.String name, java.lang.String fname, java.io.InputStream is, int len)
name
- the name of the parameter.fname
- the suggested filenameis
- the stream providing the data.public java.net.HttpURLConnection exchange(java.net.URL url) throws java.lang.Exception
conn
- the URL to post the data to,
java.lang.Exception
- on any error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |