public class HttpFileUpload extends HttpRequest
Example Usage:
Http http = new Http();
HttpFileUpload request = new HttpFileUpload("http://www.myserver.com/cgi-bin/upload.cgi");
request.addParameter("name", "John Doe");
request.setFile("picture", "joe.gif", new File("/home/joe/joe.gif");
HttpResponse response = http.getResponse(request);
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PLACEHOLDER
Place holder string for file data.
|
| Constructor and Description |
|---|
HttpFileUpload(java.lang.String url)
Constructs a new
HttpFileUpload instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(HttpParameter parameter)
Adds a query parameter to
HttpFileUpload. |
void |
addParameter(java.lang.String name,
java.lang.String value)
Adds a query parameter to
HttpFileUpload. |
boolean |
isStreamingEnabled()
Streaming.
|
void |
setFile(java.lang.String fieldName,
java.lang.String filename,
byte[] data)
Sets the file to upload for this
HttpFileUpload. |
void |
setFile(java.lang.String fieldName,
java.lang.String fileName,
java.io.File file)
Sets the file to upload for this
HttpFileUpload. |
void |
streamFileToServer(java.lang.String fieldName,
java.lang.String fileName,
java.io.File file)
Stream file to HTTP server instead of reading entire File object in RAM.
|
addCookie, addHeader, addHeader, addReplaceHeader, addReplaceHeader, addReplaceParameter, addReplaceParameter, clearCookies, clearParameters, getHttpVersion, getMessage, getMethod, getParameters, getProxyHost, getProxyPort, getProxyUsername, getURL, getUserAgent, isUTF8, setBasicAuthentication, setHttpVersion, setMethod, setProxyHost, setProxyLogin, setProxyPort, setURL, setUserAgent, setUTF8addPart, getBody, getBodyAsFile, getBodyData, getBoundary, getContentTransferEncoding, getContentType, getHeader, getHeaders, getHeaders, getHeaderValue, getPart, getParts, getRawBodyData, removeHeader, removePart, removeParts, setBody, setBody, setBody, setBody, setBodyAsFile, setContentTypepublic static final java.lang.String PLACEHOLDER
public HttpFileUpload(java.lang.String url)
throws HttpException
HttpFileUpload instance.url - the URL to post the file upload toHttpException - if a MIME related parsing error occurspublic void addParameter(java.lang.String name,
java.lang.String value)
HttpFileUpload. HTTP query
parameters are typically used in submitting form data for processing by
a CGI or servlet resident on the HTTP server. Names of query parameters
need not be unique.addParameter in class HttpRequestname - the name of the parameter to add.value - the value of the parameter to add.public void addParameter(HttpParameter parameter)
HttpFileUpload. HTTP query
parameters are typically used in submitting form data for processing by
a CGI or servlet resident on the HTTP server. Names of query parameters
need not be unique.addParameter in class HttpRequestparameter - the HttpParameter to addHttpParameterpublic boolean isStreamingEnabled()
public void streamFileToServer(java.lang.String fieldName,
java.lang.String fileName,
java.io.File file)
throws HttpException
fieldName - fileName - file - HttpExceptionpublic void setFile(java.lang.String fieldName,
java.lang.String fileName,
java.io.File file)
throws HttpException
HttpFileUpload.fieldName - the name of the field, as specified in HTML INPUT
TYPE=FILE tagfileName - the value to set the MIME filename attribute tofile - the File object of the file to be addedHttpException - if file is not foundpublic void setFile(java.lang.String fieldName,
java.lang.String filename,
byte[] data)
throws HttpException
HttpFileUpload.fieldName - the name of the field, as specified in HTML INPUT TYPE=FILE tagfilename - the value to set the MIME filename attribute todata - the data representing the file to uploadHttpException - if file is not foundCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved