| java.lang.Object | |
| ↳ | com.google.gdata.client.uploader.ResumableHttpFileUploader |
Known Direct Subclasses
|
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 Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ResumableHttpFileUploader.Builder | Builder class for constructing ResumableHttpFileUploader instances. |
||||||||||
| ResumableHttpFileUploader.RequestMethod | Http request type to use in upload requests. | ||||||||||
| ResumableHttpFileUploader.ResponseMessage | The response message returned by the upload task when it has finished uploading the last chunk. | ||||||||||
| ResumableHttpFileUploader.UploadState | Upload state associated with this file uploader. | ||||||||||
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| long | DEFAULT_PROGRESS_INTERVAL_MS | Default number of milliseconds for the progress notification interval. | |||||||||
| String | METHOD_OVERRIDE | Method-override http header. | |||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 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). | ||||||||||
| backoffPolicy | Back off policy which determines the amount of time to wait before retrying an HTTP request. | ||||||||||
| chunkSize | Maximum size of individual chunks that will get uploaded by single HTTP requests. | ||||||||||
| data | The file to upload. | ||||||||||
| executor | Executor service to execute asynchronous upload tasks. | ||||||||||
| headers | Extra http headers to send in each request. | ||||||||||
| httpRequestMethod | HTTP request method to use when uploading. | ||||||||||
| numBytesUploaded | Number of bytes that have been successfully uploaded to the server by this uploader. | ||||||||||
| progressIntervalMillis | Number of milliseconds between progress listener notifications. | ||||||||||
| progressListener | Progress listener interface instance to send progress notifications to. | ||||||||||
| progressNotifier | Timer for sending progress notifications on a fixed time interval. | ||||||||||
| uploadResultFuture | The future which will contain the eventual response stream from the upload server. | ||||||||||
| uploadState | The current state of the uploader. | ||||||||||
| url | The URL which locates the destination of the upload. | ||||||||||
| urlConnectionFactory | Factory for creating HTTP connections. | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
This constructor is deprecated.
Please use
ResumableHttpFileUploader.Builder
| |||||||||||
This constructor is deprecated.
Please use
ResumableHttpFileUploader.Builder
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Add a http header to send in each of the upload requests.
| |||||||||||
Gets the file associated with this uploader.
| |||||||||||
Returns the http request method to use for upload.
| |||||||||||
Gets the total number of bytes uploaded by this uploader.
| |||||||||||
Gets the upload progress denoting the percentage of bytes that have been
uploaded, represented between 0.0 (0%) and and 1.0 (100%).
| |||||||||||
Gets the response from the server if it is available.
| |||||||||||
Gets the current upload state of the uploader.
| |||||||||||
Identifies if the upload task has completed
| |||||||||||
Identifies if the uploader is paused
| |||||||||||
Causes the uploader to pause uploading.
| |||||||||||
Resumes an upload if it is currently paused, or if it has not yet started.
| |||||||||||
This method is deprecated.
Please use
setRequestMethod(RequestMethod)
| |||||||||||
Starts an upload beginning with the first byte in the file.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Default number of milliseconds for the progress notification interval.
Method-override http header.
Default maximum number of bytes that will be uploaded to the server in any single HTTP request (set to 10 MB).
Back off policy which determines the amount of time to wait before retrying an HTTP request.
Maximum size of individual chunks that will get uploaded by single HTTP requests.
Executor service to execute asynchronous upload tasks.
Extra http headers to send in each request.
HTTP request method to use when uploading.
Number of bytes that have been successfully uploaded to the server by this uploader.
Number of milliseconds between progress listener notifications.
Progress listener interface instance to send progress notifications to.
Timer for sending progress notifications on a fixed time interval.
The future which will contain the eventual response stream from the upload server.
The URL which locates the destination of the upload.
Factory for creating HTTP connections.
This constructor is deprecated.
Please use ResumableHttpFileUploader.Builder
Constructs a new uploader that uses the default maximum chunk size per HTTP request.
| url | Which locates the destination of the upload request |
|---|---|
| file | Containing bytes to send to the server |
| executor | Service to execute asynchronous upload tasks with |
| progressListener | For receiving progress notifications |
| progressIntervalMillis | Number of milliseconds between progress listener notifications |
| IOException | if the file is not readable or does not exist |
|---|
This constructor is deprecated.
Please use ResumableHttpFileUploader.Builder
Constructs a new uploader with configurable chunk size to use per HTTP request.
| url | Which locates the destination of the upload request |
|---|---|
| file | Containing bytes to send to the server |
| executor | Service to execute asynchronous upload tasks with |
| progressListener | For receiving progress notifications |
| chunkSize | Size of the chunks that will get uploaded by individual HTTP requests |
| progressIntervalMillis | Number of milliseconds between progress listener notifications |
| IOException | if the file is not readable or does not exist |
|---|
Add a http header to send in each of the upload requests.
| key | Http header name |
|---|---|
| value | Http header value |
Gets the file associated with this uploader.
Returns the http request method to use for upload.
Gets the total number of bytes uploaded by this uploader.
Gets the upload progress denoting the percentage of bytes that have been uploaded, represented between 0.0 (0%) and and 1.0 (100%).
Gets the response from the server if it is available. If the stream is not
yet available, null is returned.
Gets the current upload state of the uploader.
Identifies if the upload task has completed
true if the uploader is done
Identifies if the uploader is paused
true if the uploader is paused
Causes the uploader to pause uploading. The uploader may be resumed later
by calling resume(). This method does not block.
Resumes an upload if it is currently paused, or if it has not yet started. This should be called if the server has received some bytes for the file. Note that it causes an extra HTTP request to be sent to the server in order to determine the offset at which the uploader should begin sending bytes. This method does not block.
This method is deprecated.
Please use setRequestMethod(RequestMethod)
Set the http request type for upload. Resumable upload can accept either PUT request or POST request with x-http-method-override header set to PUT.
| requestMethod | Http request type |
|---|
Starts an upload beginning with the first byte in the file. This method does not block.