public async static void GetTextFromS3(IAmazonTextract textractClient, string bucketName, string keyName) { List <Block> result = null; DetectDocumentTextRequest detectTextRequest = new DetectDocumentTextRequest() { Document = new Document { S3Object = new S3Object { Bucket = bucketName, Name = keyName } } }; try { Task <DetectDocumentTextResponse> detectTask = textractClient.DetectDocumentTextAsync(detectTextRequest); DetectDocumentTextResponse detectTextResponse = await detectTask; result = detectTextResponse.Blocks; //PrintBlockDetails(result); } catch (AmazonTextractException textractException) { Console.WriteLine(textractException.Message, textractException.InnerException); } }
public async Task <List <Block> > GetTextFromStream(IAmazonTextract textractClient, MemoryStream stream) { List <Block> result = null; DetectDocumentTextRequest detectTextRequest = new DetectDocumentTextRequest() { Document = new Document { Bytes = stream } }; try { Task <DetectDocumentTextResponse> detectTask = textractClient.DetectDocumentTextAsync(detectTextRequest); DetectDocumentTextResponse detectTextResponse = await detectTask; result = detectTextResponse.Blocks; //PrintBlockDetails(result); } catch (AmazonTextractException textractException) { Console.WriteLine(textractException.Message, textractException.InnerException); } return(result); }
private Amazon.Textract.Model.DetectDocumentTextResponse CallAWSServiceOperation(IAmazonTextract client, Amazon.Textract.Model.DetectDocumentTextRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Textract", "DetectDocumentText"); try { #if DESKTOP return(client.DetectDocumentText(request)); #elif CORECLR return(client.DetectDocumentTextAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }