Ejemplo n.º 1
0
        public async Task <string> StartDocumentTextDetection(string bucketName, string key)
        {
            var request = new StartDocumentTextDetectionRequest
            {
                DocumentLocation = new DocumentLocation
                {
                    S3Object = new S3Object
                    {
                        Bucket = bucketName,
                        Name   = key
                    }
                }
            };

            var response = await _textract.StartDocumentTextDetectionAsync(request);

            return(response.JobId);
        }
 private Amazon.Textract.Model.StartDocumentTextDetectionResponse CallAWSServiceOperation(IAmazonTextract client, Amazon.Textract.Model.StartDocumentTextDetectionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Textract", "StartDocumentTextDetection");
     try
     {
         #if DESKTOP
         return(client.StartDocumentTextDetection(request));
         #elif CORECLR
         return(client.StartDocumentTextDetectionAsync(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;
     }
 }
        public async Task <IEnumerable <Block> > GetDocumentBlocks(string bucketName, string key)
        {
            var request = new StartDocumentTextDetectionRequest
            {
                DocumentLocation = new DocumentLocation {
                    S3Object = new S3Object {
                        Bucket = bucketName, Name = key
                    }
                }
            };
            var response = await _textract.StartDocumentTextDetectionAsync(request);

            var jobId = response.JobId;


            //Wait until job complete. Note: Normally you would seperate this to a distributed event or scheduler
            WaitForJobCompletion(response.JobId);

            //Get detection results
            var textDetectionResponses = GetJobResults(jobId);

            //Return all blocks
            return(textDetectionResponses.SelectMany(textDetectionResponse => textDetectionResponse.Blocks));
        }