java.lang.Object | |
↳ | com.kinvey.java.core.MediaHttpDownloader |
Media HTTP Downloader, with support for both direct and resumable media downloads. Documentation is available here.
Implementation is not thread-safe.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
enum | MediaHttpDownloader.DownloadState | Download state associated with the Media HTTP downloader. | |||||||||
class | MediaHttpDownloader.DownloadUrlResponse | This class is deprecated. No replacement. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MAXIMUM_CHUNK_SIZE | Default maximum number of bytes that will be downloaded from the server in any single HTTP request. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MediaHttpDownloader(HttpTransport transport, HttpRequestInitializer httpRequestInitializer)
Construct the
MediaHttpDownloader . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
download(AbstractKinveyClientRequest initiationClientRequest, OutputStream out)
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 |
getLastBytePosition()
Gets the last byte position of the media file we want to download or
-1 if there is no
upper limit on the byte position. | ||||||||||
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%).
| ||||||||||
DownloaderProgressListener |
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 |
setContentRange(long firstBytePos, int lastBytePos)
Sets the content range of the next download request.
| ||||||||||
MediaHttpDownloader |
setDirectDownloadEnabled(boolean directDownloadEnabled)
Returns whether direct media download is enabled or disabled.
| ||||||||||
MediaHttpDownloader |
setProgressListener(DownloaderProgressListener progressListener)
Sets the progress listener to send progress notifications to or
null for none. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Default maximum number of bytes that will be downloaded from the server in any single HTTP request. Set to 32MB because that is the maximum App Engine request size.
Construct the MediaHttpDownloader
.
transport | The transport to use for requests |
---|---|
httpRequestInitializer | The initializer to use when creating an HttpRequest or
null for none
|
Executes a direct media download or a resumable media download.
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.
initiationClientRequest | request object used to request unique uri from kinvey |
---|---|
out | output stream to dump bytes as they stream off the wire |
IOException |
---|
Returns the maximum size of individual chunks that will get downloaded by single HTTP requests.
The default value is MAXIMUM_CHUNK_SIZE
.
Gets the current download state of the downloader.
Gets the last byte position of the media file we want to download or -1
if there is no
upper limit on the byte position.
Gets the total number of bytes downloaded by this downloader.
Gets the download progress denoting the percentage of bytes that have been downloaded, represented between 0.0 (0%) and 1.0 (100%).
Returns the progress listener to send progress notifications to or null
for none.
Returns the transport to use for requests.
Returns whether the back off policy is enabled or disabled. If value is set to false
then server errors are not handled and the download process will fail if a server error is
encountered. Defaults to true
.
Returns whether direct media download is enabled or disabled. If value is set to 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
.
Sets whether the back off policy is enabled or disabled. If value is set to false
then
server errors are not handled and the download process will fail if a server error is
encountered. Defaults to true
.
Sets the total number of bytes that have been downloaded of the media resource.
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.
Use setContentRange(long, int)
if you need to specify both the bytes downloaded and the last byte
position.
bytesDownloaded | The total number of bytes downloaded |
---|
Sets the maximum size of individual chunks that will get downloaded by single HTTP requests.
The default value is MAXIMUM_CHUNK_SIZE
.
The maximum allowable value is MAXIMUM_CHUNK_SIZE
.
Sets the content range of the next download request. Eg: bytes=firstBytePos-lastBytePos.
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.
Use setBytesDownloaded(long)
if you only need to specify the first byte position.
firstBytePos | The first byte position in the content range string |
---|---|
lastBytePos | The last byte position in the content range string. |
Returns whether direct media download is enabled or disabled. If value is set to 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
.
Sets the progress listener to send progress notifications to or null
for none.