public class HTTPFileUpload
extends java.util.Observable
Modifier and Type | Class and Description |
---|---|
protected class |
HTTPFileUpload.FileInfo |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BOUNDARY |
protected static java.lang.String |
CR_LF |
protected java.util.ArrayList<HTTPFileUpload.FileInfo> |
filesToUpload |
protected int |
maxBufferSize |
protected java.lang.String |
requestMethod |
protected AVList |
requestProperties |
protected long |
totalBytesToUpload |
protected long |
totalBytesUploaded |
protected int |
totalFilesFailed |
protected int |
totalFilesUploaded |
protected static java.lang.String |
TWO_HYPHENS |
protected java.net.URL |
url |
Constructor and Description |
---|
HTTPFileUpload(java.net.URL url) |
Modifier and Type | Method and Description |
---|---|
void |
add(java.nio.ByteBuffer bufferToUpload,
java.lang.String name,
AVList params) |
void |
add(java.io.File file,
java.lang.String name,
AVList params)
Adds a file to the HTTP File Uploader.
|
protected void |
disconnect(java.net.HttpURLConnection conn,
java.lang.String name) |
int |
getMaxBufferSize() |
java.lang.String |
getRequestMethod()
Returns the HTTP request method - POST or GET
|
long |
getTotalBytesToUpload() |
long |
getTotalBytesUploaded() |
int |
getTotalFilesFailed() |
long |
getTotalFilesToUpload() |
int |
getTotalFilesUploaded() |
protected void |
handleResponse(java.net.HttpURLConnection conn) |
protected void |
notifyProgress() |
void |
send() |
protected void |
send(java.nio.ByteBuffer bufferToUpload,
java.lang.String fileName,
AVList params) |
protected void |
send(java.io.File fileToUpload,
java.lang.String uploadName,
AVList params) |
protected void |
send(java.lang.String stringToUpload,
java.lang.String fileName,
AVList params) |
void |
setMaxBufferSize(int maxBufferSize) |
void |
setRequestMethod(java.lang.String method)
Sets a HTTP request method - POST or GET
|
void |
setRequestProperty(java.lang.String name,
java.lang.String value) |
protected void |
writeContentDisposition(java.io.DataOutputStream dos,
java.lang.String filename) |
protected void |
writeContentDisposition(java.io.DataOutputStream dos,
java.lang.String paramName,
java.lang.String paramValue) |
protected void |
writeContentSeparator(java.io.DataOutputStream dos) |
protected void |
writeProperties(java.io.DataOutputStream dos,
AVList params) |
protected void |
writeRequestProperties(java.net.HttpURLConnection conn)
Writes HTTP request' properties (HTTP headers)
|
protected static final java.lang.String BOUNDARY
protected static final java.lang.String CR_LF
protected java.util.ArrayList<HTTPFileUpload.FileInfo> filesToUpload
protected int maxBufferSize
protected java.lang.String requestMethod
protected AVList requestProperties
protected long totalBytesToUpload
protected long totalBytesUploaded
protected int totalFilesFailed
protected int totalFilesUploaded
protected static final java.lang.String TWO_HYPHENS
protected final java.net.URL url
public void add(java.nio.ByteBuffer bufferToUpload, java.lang.String name, AVList params)
public void add(java.io.File file, java.lang.String name, AVList params) throws java.io.FileNotFoundException
file
- The file to upload, must existname
- The desired name of the fileparams
- AVList of parametersjava.io.FileNotFoundException
- if the file was not found or does not existprotected void disconnect(java.net.HttpURLConnection conn, java.lang.String name)
public int getMaxBufferSize()
public java.lang.String getRequestMethod()
public long getTotalBytesToUpload()
public long getTotalBytesUploaded()
public int getTotalFilesFailed()
public long getTotalFilesToUpload()
public int getTotalFilesUploaded()
protected void handleResponse(java.net.HttpURLConnection conn) throws java.io.IOException
java.io.IOException
protected void notifyProgress()
public void send() throws java.lang.Exception
java.lang.Exception
protected void send(java.nio.ByteBuffer bufferToUpload, java.lang.String fileName, AVList params) throws java.io.IOException
java.io.IOException
protected void send(java.io.File fileToUpload, java.lang.String uploadName, AVList params) throws java.io.IOException, java.lang.NullPointerException
java.io.IOException
java.lang.NullPointerException
protected void send(java.lang.String stringToUpload, java.lang.String fileName, AVList params) throws java.io.IOException
java.io.IOException
public void setMaxBufferSize(int maxBufferSize)
public void setRequestMethod(java.lang.String method)
method
- POST or GETpublic void setRequestProperty(java.lang.String name, java.lang.String value)
protected void writeContentDisposition(java.io.DataOutputStream dos, java.lang.String filename) throws java.io.IOException
java.io.IOException
protected void writeContentDisposition(java.io.DataOutputStream dos, java.lang.String paramName, java.lang.String paramValue) throws java.io.IOException
java.io.IOException
protected void writeContentSeparator(java.io.DataOutputStream dos) throws java.io.IOException
java.io.IOException
protected void writeProperties(java.io.DataOutputStream dos, AVList params) throws java.io.IOException
java.io.IOException
protected void writeRequestProperties(java.net.HttpURLConnection conn) throws java.io.IOException
conn
- HttpURLConnection connectionjava.io.IOException
- if there is any problem with a connection