uploadAsync()

Description

Uploads images asynchronously. The selected image data in DcsBuffer will be encoded according to the value of encodeParameter and uploaded to the specified HTTP server.

Syntax

func uploadAsync (indice:[Any], uploadConfig:DcsHttpUploadConfig, encodeParameter:DcsEncodeParameter, onSuccess:onUploadSuccess, onFailure:onUploadFailure, onProgress:onUploadProgress)

Parameters

indices:[Any] An index array for images to be uploaded.
uploadConfig:DcsHttpUploadConfig Configuration for HTTP upload.
encodeParameter:DcsEncodeParameter Its value will be chosen from DcsPNGEncodeParameter, DcsJPEGEncodeParameter or DcsPDFEncodeParameter which represents to save the images as PNG, JPG or PDF files.
onSuccess:onUploadSuccess The callback function when this method performs successfully.
onFailure:onUploadFailure The callback function when this method performs unsuccessfully.
onProgress:onUploadProgress The callback function when this method pushes load progress information.

Return value

Data

Remarks

encodeParameter Maximum Value Result if the value exceeds the maximum value
DcsPNGEncodeParameter 1 Upload the first image as PNG file.
DcsJPEGEncodeParameter 1 Upload the first image as JPG file.
DcsPDFEncodeParameter no limit Upload the images as multi-page PDF.

Exceptions

Circumstance Exception thrown
License verification failed. DcsLicenseVerificationFailedException
Upload fails due to the network issue. DcsHttpErrorException
No network connection. DcsNetworkDisconnectedException
Indices/encodeParameter/file is nil. DcsValueNotValidException
Indices include a value not smaller than DcsBuffer.count. DcsValueOutOfRangeException
typealias onUploadSuccess = (data: Data) -> Void
Description This event is triggered when uploadAsync function is successfully executed.
Parameter data: The returned data message when uploadAsync function is successfully executed.
typealias onUploadFailure = (userData:Any exception: DcsException) -> Void
Description This event is triggered when uploadAsync function is not successfully executed.
Parameter exception: The exception uploadAsync throws.
onUploadProgress = (progress: Int)-> Bool
Description This event is triggered when uploadAsync function is executing and showing the progress.
Parameter progress: The progress of uploading.
Return When YES is returned, uploadAsync will keep executing. When NO is returned, uploadAsync will stop.