interface PakDownloader
download
(
uri
, outFile
, resumeFromByte
, sink
)
|
Starts downloading PakDownloader.download into PakDownloader.download, optionally resuming from PakDownloader.download.
The implementation writes directly to PakDownloader.download (append mode if resuming). Progress and completion are reported via PakDownloader.download.
This method is called on a background thread. It may block or use async I/O internally — the contract is that PakDownloader.download callbacks are the completion signal.
Signature
abstract fun download(uri: Uri, outFile: File, resumeFromByte: Long, sink: PakDownloader.ProgressSink) Parameters uri: UrioutFile: FileresumeFromByte: Longsink: PakDownloader.ProgressSink |
download
(
uri
, outFile
, resumeFromByte
, sink
, headers
)
|
Starts downloading PakDownloader.download into PakDownloader.download with additional HTTP PakDownloader.download.
Override this to support authorization headers, API keys, or CDN-specific headers. The default implementation delegates to the 4-param PakDownloader.download, ignoring headers — override if your transport needs them.
Signature
open fun download(uri: Uri, outFile: File, resumeFromByte: Long, sink: PakDownloader.ProgressSink, headers: Map<String, String>) Parameters uri: UrioutFile: FileresumeFromByte: Longsink: PakDownloader.ProgressSinkheaders: Map
Additional HTTP headers (e.g. "Authorization" to "Bearer <token>").
|
download
(
uri
, outFile
, resumeFromByte
, sink
, headers
, refreshAuthHeaders
)
|
Starts downloading PakDownloader.download into PakDownloader.download with HTTP PakDownloader.download and an optional auth-failure refresh callback.
Override this if your transport supports auth refresh (e.g. on 401/403 the downloader calls PakDownloader.download with the status code, and if it returns non-null, retries the request once with the new headers). The default implementation delegates to the 5-param overload, ignoring PakDownloader.download.
Signature
open fun download(uri: Uri, outFile: File, resumeFromByte: Long, sink: PakDownloader.ProgressSink, headers: Map<String, String>, refreshAuthHeaders: (Int) -> Map<String, String>??) Parameters uri: UrioutFile: FileresumeFromByte: Longsink: PakDownloader.ProgressSinkheaders: MaprefreshAuthHeaders: Function1? |
interface ProgressSink
isCancelled
: Boolean
[Get] |
Returns true if the download has been cancelled by the caller.
Signature
abstract val isCancelled: Boolean |
onComplete
()
|
Download completed successfully. The file is fully written.
Signature
abstract fun onComplete() |
onError
(
exception
)
|
Download failed.
Signature
abstract fun onError(exception: Exception) Parameters exception: Exception |
onProgress
(
bytesDownloaded
, totalBytes
)
|
Report bytes written so far (cumulative, including resumed bytes).
Signature
abstract fun onProgress(bytesDownloaded: Long, totalBytes: Long?) Parameters bytesDownloaded: LongtotalBytes: Long? |