【发布时间】:2022-01-26 07:45:39
【问题描述】:
我有一个 .Net 核心客户端应用程序,根据 AWS 文档使用带有 S3、SNS 和 SQS 的 amazon Textract,检测和分析多页文档中的文本 (https://docs.aws.amazon.com/textract/latest/dg/async.html)
使用 AmazonTextractServiceRole 策略创建了一个 AWS 角色,并根据文档 (https://docs.aws.amazon.com/textract/latest/dg/api-async-roles.html) 添加了以下信任关系 { “版本”:“2012-10-17”, “陈述”: [ { “效果”:“允许”, “主要的”: { “服务”:“textract.amazonaws.com” }, “动作”:“sts:AssumeRole” } ] }
订阅 SQS 到该主题并根据 aws 文档授予 Amazon SNS 主题向 Amazon SQS 队列发送消息的权限。
所有资源,包括 S3 Bucket、SNS、SQS 都在同一个 us-west2 区域中
以下方法显示一般错误“InvalidParameterException” 请求的参数无效
但如果 NotificationChannel 部分被注释,则代码工作正常并返回正确的作业 ID。
错误消息没有给出关于参数的清晰图片。非常感谢任何帮助。
public async Task<string> ScanDocument()
{
string roleArn = "aws:iam::xxxxxxxxxxxx:instance-profile/MyTextractRole";
string topicArn = "aws:sns:us-west-2:xxxxxxxxxxxx:AmazonTextract-My-Topic";
string bucketName = "mybucket";
string filename = "mytestdoc.pdf";
var request = new StartDocumentAnalysisRequest();
var notificationChannel = new NotificationChannel();
notificationChannel.RoleArn = roleArn;
notificationChannel.SNSTopicArn = topicArn;
var s3Object = new S3Object
{
Bucket = bucketName,
Name = filename
};
request.DocumentLocation = new DocumentLocation
{
S3Object = s3Object
};
request.FeatureTypes = new List<string>() { "TABLES", "FORMS" };
request.NotificationChannel = channel; /* Commenting this line work the code*/
var response = await this._textractService.StartDocumentAnalysisAsync(request);
return response.JobId;
}
【问题讨论】:
标签: amazon-web-services .net-core amazon-textract