|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.client.uploader.ResumableHttpFileUploader
public class ResumableHttpFileUploader
Uploads a file using resumable HTTP requests (see "http://code.google.com/p/gears/wiki/ResumableHttpRequestsProposal"). This implementation supports time based progress notifications, polling for progress, resumability, and completion notifications. Each instance creates a separate task (to be executed by an ExecutorService), which actually generates the HTTP request and writes bytes to the server. The task blocks a thread spawned by the ExecutorService) for the duration of the upload (i.e., until the upload is either completed, paused, or an error occurs). This frees the current thread from blocking, which allows various non-blocking interaction with the uploader (like polling for progress, preventing UI from being blocked, etc.).
Nested Class Summary | |
---|---|
static class |
ResumableHttpFileUploader.Builder
Builder class for constructing ResumableHttpFileUploader instances. |
static class |
ResumableHttpFileUploader.RequestMethod
Http request type to use in upload requests. |
static class |
ResumableHttpFileUploader.ResponseMessage
The response message returned by the upload task when it has finished uploading the last chunk. |
static class |
ResumableHttpFileUploader.UploadState
Upload state associated with this file uploader. |
Field Summary | |
---|---|
static long |
DEFAULT_MAX_CHUNK_SIZE
Default maximum number of bytes that will be uploaded to the server in any single HTTP request (set to 10 MB). |
static long |
DEFAULT_PROGRESS_INTERVAL_MS
Default number of milliseconds for the progress notification interval. |
static java.lang.String |
METHOD_OVERRIDE
Method-override http header. |
Constructor Summary | |
---|---|
ResumableHttpFileUploader(java.net.URL url,
java.io.File file,
java.util.concurrent.ExecutorService executor,
ProgressListener progressListener,
long progressIntervalMillis)
Deprecated. Please use ResumableHttpFileUploader.Builder |
|
ResumableHttpFileUploader(java.net.URL url,
java.io.File file,
java.util.concurrent.ExecutorService executor,
ProgressListener progressListener,
long chunkSize,
long progressIntervalMillis)
Deprecated. Please use ResumableHttpFileUploader.Builder |
Method Summary | |
---|---|
java.lang.String |
addHeader(java.lang.String key,
java.lang.String value)
Add a http header to send in each of the upload requests. |
UploadData |
getData()
Gets the file associated with this uploader. |
ResumableHttpFileUploader.RequestMethod |
getHttpRequestMethod()
Returns the http request method to use for upload. |
long |
getNumBytesUploaded()
Gets the total number of bytes uploaded by this uploader. |
double |
getProgress()
Gets the upload progress denoting the percentage of bytes that have been uploaded, represented between 0.0 (0%) and and 1.0 (100%). |
ResumableHttpFileUploader.ResponseMessage |
getResponse()
Gets the response from the server if it is available. |
ResumableHttpFileUploader.UploadState |
getUploadState()
Gets the current upload state of the uploader. |
boolean |
isDone()
Identifies if the upload task has completed |
boolean |
isPaused()
Identifies if the uploader is paused |
void |
pause()
Causes the uploader to pause uploading. |
void |
resume()
Resumes an upload if it is currently paused, or if it has not yet started. |
void |
setHttpRequestMethod(ResumableHttpFileUploader.RequestMethod requestMethod)
Deprecated. Please use ResumableHttpFileUploader.Builder#setRequestMethod(RequestMethod) |
java.util.concurrent.Future<ResumableHttpFileUploader.ResponseMessage> |
start()
Starts an upload beginning with the first byte in the file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static long DEFAULT_MAX_CHUNK_SIZE
public static final long DEFAULT_PROGRESS_INTERVAL_MS
public static final java.lang.String METHOD_OVERRIDE
Constructor Detail |
---|
@Deprecated public ResumableHttpFileUploader(java.net.URL url, java.io.File file, java.util.concurrent.ExecutorService executor, ProgressListener progressListener, long progressIntervalMillis) throws java.io.IOException
ResumableHttpFileUploader.Builder
url
- which locates the destination of the upload requestfile
- containing bytes to send to the serverexecutor
- service to execute asynchronous upload tasks withprogressListener
- for receiving progress notificationsprogressIntervalMillis
- number of milliseconds between
progress listener notifications
java.io.IOException
- if the file is not readable or does not exist@Deprecated public ResumableHttpFileUploader(java.net.URL url, java.io.File file, java.util.concurrent.ExecutorService executor, ProgressListener progressListener, long chunkSize, long progressIntervalMillis) throws java.io.IOException
ResumableHttpFileUploader.Builder
url
- which locates the destination of the upload requestfile
- containing bytes to send to the serverexecutor
- service to execute asynchronous upload tasks withprogressListener
- for receiving progress notificationschunkSize
- size of the chunks that will get uploaded by individual
HTTP requestsprogressIntervalMillis
- number of milliseconds between
progress listener notifications
java.io.IOException
- if the file is not readable or does not existMethod Detail |
---|
@Deprecated public void setHttpRequestMethod(ResumableHttpFileUploader.RequestMethod requestMethod)
ResumableHttpFileUploader.Builder#setRequestMethod(RequestMethod)
requestMethod
- http request typepublic ResumableHttpFileUploader.RequestMethod getHttpRequestMethod()
public java.lang.String addHeader(java.lang.String key, java.lang.String value)
key
- http header namevalue
- http header value
public long getNumBytesUploaded()
public double getProgress()
public ResumableHttpFileUploader.ResponseMessage getResponse()
null
is returned.
public ResumableHttpFileUploader.UploadState getUploadState()
public boolean isPaused()
true
if the uploader is pausedpublic void pause()
resume()
. This method does not block.
public void resume()
public java.util.concurrent.Future<ResumableHttpFileUploader.ResponseMessage> start()
public boolean isDone()
true
if the uploader is donepublic UploadData getData()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |