Skip to main content

Download Files

Enqueue File#

To download a file, you need to add it to the download queue:

clfm.downloader.enqueueFile(item, toDestination: path)

After the directory has been reloaded (see chapter Read Directory Content), the corresponding FileItems property operation will contain a reference to the OperationDownload object with the float property progress. This property is used to display the download progress.

To cancel the download, you need to call CloudikeFilesManager.shared.downloader.cancelFile(fileItem).

Monitor Download Status#

To monitor download status you can subscribe on FileManager.shared.downloader.downloadStatus. The following example shows how to do that:

private fun subscribeOnDownloadStatusUpdates() {    clfm.downloader.downloadStatus        .flatMap({ event -> Observable<DownloaderEvent> in            return Observable.just(event)        })        .subscribe({ [weak self] event in            self?.progressView.setProgress(Float(event.element?.progress ?? 0), animated: false)            self?.countLabel.text = "\(event.element?.filesLeft ?? 0)"        })        .disposed(by: disposeBag)