public void Verify([FromBody] VerifyImageDataRequestViewModel request) { IOcrService ocrService = new GoogleVisionService(); string serviceName = ocrService.Service; IFileStorageService fsService = new AzureBlobStorageService(serviceName); fsService.MoveToSubFolderAsync(request.ScanId, request.Status.ToString()); }
public async Task <ScanResultViewModel> Passport() { Byte[] frontImageBytes = null, backImageBytes = null; string fileName = string.Empty; try { if (Request.HttpContext.Request.Form.Files["frontside"].FileName != null) { var imageFrontStream = Request.HttpContext.Request.Form.Files["frontside"].OpenReadStream(); fileName = Request.HttpContext.Request.Form.Files["frontside"].FileName; Int32 forntLength = imageFrontStream.Length > Int32.MaxValue ? Int32.MaxValue : Convert.ToInt32(imageFrontStream.Length); frontImageBytes = new Byte[forntLength]; imageFrontStream.Read(frontImageBytes, 0, forntLength); } } catch (Exception) { } try { if (Request.HttpContext.Request.Form.Files["backside"].FileName != null) { var imageBackStream = Request.HttpContext.Request.Form.Files["backside"].OpenReadStream(); Int32 backLength = imageBackStream.Length > Int32.MaxValue ? Int32.MaxValue : Convert.ToInt32(imageBackStream.Length); backImageBytes = new Byte[backLength]; imageBackStream.Read(backImageBytes, 0, backLength); } } catch (Exception) { } IOcrService ocrService = new GoogleVisionService(); string serviceName = ocrService.Service; IFileStorageService fsService = new AzureBlobStorageService(serviceName); ScanResultViewModel scanResult = new ScanResultViewModel(); scanResult.ScanId = await fsService.StoreImageAsync(frontImageBytes, backImageBytes); scanResult.Data = await ocrService.ScanPassportAsync(frontImageBytes, backImageBytes, fileName); return(scanResult); }