downloadAsync()

Description

Downloads images asynchronously and converts them to dcsImage or dcsDocument in DcsBuffer according to the value of mode.

Syntax

func downloadAsync(config:DcsHttpDownloadConfig, mode:DcsModeEnum, onSuccess:onDownloadSuccess, onFailure:onDownloadFailure, onProgress:onDownloadProgress)

Parameters

config:config Configuration for HTTP download.
mode:DcsModeEnum Indicates if the downloaded files are images or documents.
onSuccess:onDownloadSuccess The callback function when this method performs successfully.
onFailure:onDownloadFailure The callback function when this method performs unsuccessfully.
onProgress:onDownloadProgress The callback function when this method pushes load progress information.

Return value

Void

Exceptions

Circumstance Exception thrown
License verification failed. DcsLicenseVerificationFailedException
Downloaded files are not able to decode. DcsDataFormatInvalidException
Download fails due to the network issue. DcsHttpErrorException
No network connection. DcsNetworkDisconnectedException
config is nil or there are errors in data. DcsValueNotValidException
Mode is not DME_DOCUMENT nor DME_IMAGE. DcsValueOutOfRangeException
typealias onDownloadSuccess = () -> Void
Description This event is triggered when downloadAsync function is successfully executed.
Parameter data: The returned data message when downloadAsync function is successfully executed.
typealias onDownloadFailure = (exception: DcsException) -> Void
Description This event is triggered when downloadAsync function is not successfully executed.
Parameter exception: The exception downloadAsync throws.
typealias onDownloadProgress = (progress: Int)-> Bool
Description This event is triggered when downloadAsync function is executing and showing the progress.
Parameter progress: The progress of downloading.
Return When YES is returned, downloadAsync will keep executing. When NO is returned, downloadAsync will stop.
Is this page helpful?

Leave a Reply

Your email address will not be published.