gov.nasa.worldwind.util
Class HTTPFileUpload
java.lang.Object
java.util.Observable
gov.nasa.worldwind.util.HTTPFileUpload
public class HTTPFileUpload
- extends Observable
Synchronous file upload using HTTP POST as a multi-part form data
|
Method Summary |
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) |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BOUNDARY
protected static final String BOUNDARY
- See Also:
- Constant Field Values
CR_LF
protected static final String CR_LF
- See Also:
- Constant Field Values
filesToUpload
protected ArrayList<HTTPFileUpload.FileInfo> filesToUpload
maxBufferSize
protected int maxBufferSize
requestMethod
protected String requestMethod
requestProperties
protected AVList requestProperties
totalBytesToUpload
protected long totalBytesToUpload
totalBytesUploaded
protected long totalBytesUploaded
totalFilesFailed
protected int totalFilesFailed
totalFilesUploaded
protected int totalFilesUploaded
TWO_HYPHENS
protected static final String TWO_HYPHENS
- See Also:
- Constant Field Values
url
protected final URL url
HTTPFileUpload
public HTTPFileUpload(URL url)
add
public void add(ByteBuffer bufferToUpload,
String name,
AVList params)
add
public void add(File file,
String name,
AVList params)
throws FileNotFoundException
- Adds a file to the HTTP File Uploader.
- Parameters:
file - The file to upload, must existname - The desired name of the fileparams - AVList of parameters
- Throws:
FileNotFoundException - if the file was not found or does not exist
disconnect
protected void disconnect(HttpURLConnection conn,
String name)
getMaxBufferSize
public int getMaxBufferSize()
getRequestMethod
public String getRequestMethod()
- Returns the HTTP request method - POST or GET
- Returns:
- POST or GET
getTotalBytesToUpload
public long getTotalBytesToUpload()
getTotalBytesUploaded
public long getTotalBytesUploaded()
getTotalFilesFailed
public int getTotalFilesFailed()
getTotalFilesToUpload
public long getTotalFilesToUpload()
getTotalFilesUploaded
public int getTotalFilesUploaded()
handleResponse
protected void handleResponse(HttpURLConnection conn)
throws IOException
- Throws:
IOException
notifyProgress
protected void notifyProgress()
send
public void send()
throws Exception
- Throws:
Exception
send
protected void send(ByteBuffer bufferToUpload,
String fileName,
AVList params)
throws IOException
- Throws:
IOException
send
protected void send(File fileToUpload,
String uploadName,
AVList params)
throws IOException,
NullPointerException
- Throws:
IOException
NullPointerException
send
protected void send(String stringToUpload,
String fileName,
AVList params)
throws IOException
- Throws:
IOException
setMaxBufferSize
public void setMaxBufferSize(int maxBufferSize)
setRequestMethod
public void setRequestMethod(String method)
- Sets a HTTP request method - POST or GET
- Parameters:
method - POST or GET
setRequestProperty
public void setRequestProperty(String name,
String value)
writeContentDisposition
protected void writeContentDisposition(DataOutputStream dos,
String filename)
throws IOException
- Throws:
IOException
writeContentDisposition
protected void writeContentDisposition(DataOutputStream dos,
String paramName,
String paramValue)
throws IOException
- Throws:
IOException
writeContentSeparator
protected void writeContentSeparator(DataOutputStream dos)
throws IOException
- Throws:
IOException
writeProperties
protected void writeProperties(DataOutputStream dos,
AVList params)
throws IOException
- Throws:
IOException
writeRequestProperties
protected void writeRequestProperties(HttpURLConnection conn)
throws IOException
- Writes HTTP request' properties (HTTP headers)
- Parameters:
conn - HttpURLConnection connection
- Throws:
IOException - if there is any problem with a connection