httpDownloadAsync()

Description

Downloads an image from the HTTP server into an image viewer asynchronously.

Syntax

ImageViewerObject.io.httpDownloadAsync(url, onHttpDownloadSuccess, onHttpDownloadFailure [, onHttpDownloading]));

Parameters

<string> url: specifies the URL to download the file.
<onHttpDownloadSuccess function> onHttpDownloadSuccess: callback function triggered when the file is downloaded successfully.
<onHttpDownloadFailure function> onHttpDownloadFailure: callback function triggered when the file failed to be downloaded.
<onhttpdownloading function> optional onHttpDownloading: callback function triggered during downloading image.

Please refer to the function prototype onHttpDownloadSuccess or onHttpDownloadFailure. or onHttpDownloading.

Return value

void

Remarks

This method only supports downloading BMP, JPEG, PNG, TIFF and PDF files.

When the file fails to be loaded into the viewer, please check errorCode, errorString and httpResponse in failure callback function for more information.

Previously selected images will be deselected and the newly loaded image will be selected automatically.

When image buffer is full, that is count equals capacity, the downloaded image will not be imported into the image buffer.

Example

/****Get image01.png from: http://www.dynamsoft.com/images/image01.png****/
var imageviewer = DCSObject.getImageViewer ("ImageViewerContainer");  // Get a specified image viewer
imageviewer.io.httpDownloadAsync('www.dynamsoft.com/images/image01.png', onHttpDownloadSuccess, onHttpDownloadFailure, onHttpDownloading);

function onHttpDownloadSuccess () {
    console.log('successful'); 
}

function onHttpDownloadFailure (errorCode, errorString, httpResponse) {
    console.log("ErrorCode: " + errorCode+ "ErrorString: " + errorString + "HTTPResponseString: " + httpResponse);
}

function onHttpDownloading (percentage) {

}

See also

.io.httpDownload()

Is this page helpful?

Leave a Reply

Your email address will not be published.