interface PakDownloader
download
(
uri
, outFile
, resumeFromByte
, sink
)
|
Starts downloading uri into outFile, optionally resuming from resumeFromByte.
The implementation writes directly to outFile (append mode if resuming). Progress and completion are reported via sink.
This method is called on a background thread. It may block or use async I/O internally — the contract is that sink 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 uri into outFile with additional HTTP headers.
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 uri into outFile with HTTP headers and an optional auth-failure refresh callback.
Override this if your transport supports auth refresh (e.g. on 401/403 the downloader calls refreshAuthHeaders 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 refreshAuthHeaders.
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? |