public async Task <IActionResult> Upload(IFormFile file) { ReceiptImage receiptImage; using (var stream = new MemoryStream()) { await file.OpenReadStream().CopyToAsync(stream); var image = stream.ToArray(); /* This code only for Ivan Freyuk * var response = GetScannedReceipt(image, file.FileName).Result; * ByteArrayToImage(response.ScannedFile); */ /*Comment next variable if you uncomment code above*/ var response = new DocumentScannResponse { FileExtension = ".png", ScannedFile = image }; receiptImage = new ReceiptImage { OriginalImageName = file.FileName, OriginalImage = image, ScannedImageName = string.Concat(Guid.NewGuid().ToString("N").Substring(0, 5), response.FileExtension), ScannedImage = response.ScannedFile }; var id = _receiptImageService.Add(receiptImage); return(RedirectToAction("Index", "JsonFile", new { id })); } }