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