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 = @"https://192.168.8.93:443/DCS_iOS/UploadedImages/luffy.jpg";
        //DownloadConfig.header = nil;
        
        [dcsView.io 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.name, exception.reason);} progressUpdateCallback:^BOOL(NSInteger progress){NSLog(@"DownloadAsync on going with %ld percents done", progress);return YES;}];

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.