|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.googleapis.media.MediaHttpDownloader
public final class MediaHttpDownloader
Media HTTP Downloader, with support for both direct and resumable media downloads. Documentation is available here.
Implementation is not thread-safe.
Nested Class Summary | |
---|---|
static class |
MediaHttpDownloader.DownloadState
Download state associated with the Media HTTP downloader. |
Field Summary | |
---|---|
static int |
MAXIMUM_CHUNK_SIZE
Default maximum number of bytes that will be downloaded from the server in any single HTTP request. |
Constructor Summary | |
---|---|
MediaHttpDownloader(HttpTransport transport,
HttpRequestInitializer httpRequestInitializer)
Construct the MediaHttpDownloader . |
Method Summary | |
---|---|
void |
download(GenericUrl requestUrl,
OutputStream outputStream)
Executes a direct media download or a resumable media download. |
int |
getChunkSize()
Returns the maximum size of individual chunks that will get downloaded by single HTTP requests. |
MediaHttpDownloader.DownloadState |
getDownloadState()
Gets the current download state of the downloader. |
long |
getNumBytesDownloaded()
Gets the total number of bytes downloaded by this downloader. |
double |
getProgress()
Gets the download progress denoting the percentage of bytes that have been downloaded, represented between 0.0 (0%) and 1.0 (100%). |
MediaHttpDownloaderProgressListener |
getProgressListener()
Returns the progress listener to send progress notifications to or null for none. |
HttpTransport |
getTransport()
Returns the transport to use for requests. |
boolean |
isBackOffPolicyEnabled()
Returns whether the back off policy is enabled or disabled. |
boolean |
isDirectDownloadEnabled()
Returns whether direct media download is enabled or disabled. |
MediaHttpDownloader |
setBackOffPolicyEnabled(boolean backOffPolicyEnabled)
Sets whether the back off policy is enabled or disabled. |
MediaHttpDownloader |
setBytesDownloaded(long bytesDownloaded)
Sets the total number of bytes that have been downloaded of the media resource. |
MediaHttpDownloader |
setChunkSize(int chunkSize)
Sets the maximum size of individual chunks that will get downloaded by single HTTP requests. |
MediaHttpDownloader |
setDirectDownloadEnabled(boolean directDownloadEnabled)
Returns whether direct media download is enabled or disabled. |
MediaHttpDownloader |
setProgressListener(MediaHttpDownloaderProgressListener progressListener)
Sets the progress listener to send progress notifications to or null for none. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAXIMUM_CHUNK_SIZE
Constructor Detail |
---|
public MediaHttpDownloader(HttpTransport transport, HttpRequestInitializer httpRequestInitializer)
MediaHttpDownloader
.
transport
- The transport to use for requestshttpRequestInitializer
- The initializer to use when creating an HttpRequest
or
null
for noneMethod Detail |
---|
public void download(GenericUrl requestUrl, OutputStream outputStream) throws IOException
This method does not close the given output stream.
This method is not reentrant. A new instance of MediaHttpDownloader
must be
instantiated before download called be called again.
requestUrl
- The request URL where the download requests will be sentoutputStream
- destination output stream
IOException
public MediaHttpDownloader setBytesDownloaded(long bytesDownloaded)
If a download was aborted mid-way due to a connection failure then users can resume the download from the point where it left off.
This method is only applicable for resumable media download.
bytesDownloaded
- The total number of bytes downloadedpublic boolean isDirectDownloadEnabled()
true
then a direct download will be done where the whole media content is downloaded in a single
request. If value is set to false
then the download uses the resumable media download
protocol to download in data chunks. Defaults to false
.
public MediaHttpDownloader setDirectDownloadEnabled(boolean directDownloadEnabled)
true
then a direct download will be done where the whole media content is downloaded in a single
request. If value is set to false
then the download uses the resumable media download
protocol to download in data chunks. Defaults to false
.
public MediaHttpDownloader setProgressListener(MediaHttpDownloaderProgressListener progressListener)
null
for none.
public MediaHttpDownloaderProgressListener getProgressListener()
null
for none.
public MediaHttpDownloader setBackOffPolicyEnabled(boolean backOffPolicyEnabled)
false
then
server errors are not handled and the download process will fail if a server error is
encountered. Defaults to true
.
public boolean isBackOffPolicyEnabled()
false
then server errors are not handled and the download process will fail if a server error is
encountered. Defaults to true
.
public HttpTransport getTransport()
public MediaHttpDownloader setChunkSize(int chunkSize)
MAXIMUM_CHUNK_SIZE
.
The maximum allowable value is MAXIMUM_CHUNK_SIZE
.
public int getChunkSize()
MAXIMUM_CHUNK_SIZE
.
public long getNumBytesDownloaded()
public MediaHttpDownloader.DownloadState getDownloadState()
public double getProgress()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |