Download images/documents from the web

We can call our built-in HTTP download method to download the image(s) or document(s) asynchronously to DcsBuffer.

Format Method
PNG, JPEG, PDF downloadAsync() Swift, Objective-C

DcsHttpDownloadConfig *DownloadConfig = [DcsHttpDownloadConfig alloc];
        DownloadConfig.url = @"";
        //DownloadConfig.header = nil;
        [ downloadAsync:DownloadConfig mode:DME_IMAGE successCallback:^(NSData* data){NSString *str = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];NSLog(@"DownloadAsync succeeds! data: %@", str);} failureCallback:^(DcsException *exception){NSLog(@"DownloadAsync fails with exception: %@,%@",, exception.reason);} progressUpdateCallback:^BOOL(NSInteger progress){NSLog(@"DownloadAsync on going with %ld percents done", progress);return YES;}];

    @objc func IODownloadAsync() {
        var config=DcsHttpDownloadConfig()
        config.url="", mode: DME_IMAGE, successCallback: { (data) in
        }, failureCallback: { (exp) in
        }) { (progress) -> Bool in
            return true

With the above code, the image will be downloaded into DcsBuffer as dcsImage.

This is especially useful when you want to review an image/a document created and uploaded by Dynamsoft Camera SDK.

Is this page helpful?

Leave a Reply

Your email address will not be published.