download
suspend fun download(url: String, destinationFile: File, queryParameters: Iterable<Request.Parameter> = emptyList(), progressListener: (totalBytes: Long?, bytesRead: Long) -> Unit? = null): Result<Unit>
Downloads a file from the given URL to the specified destination and reports the progress.
Return
a Result indicating if the download is successful or not
Since
200.2.0
Parameters
url
the URL for which to download a file for
destination File
the destination file where the downloaded file will be saved. Note that any existing file will be overridden by the downloaded data.
query Parameters
any request query parameters to be included in the URL
progress Listener
a lambda to listen to download progress. The lambda will be invoked with two parameters:
totalBytes
: the total size of the file in bytes. This parameter can be null if the total size is unknown.bytesRead
: the number of bytes that have been read and written to the destination file while the download is in progress