致电AnalyzeDocument时会收到Amazon.Textract.Model.AccessDeniedException
:
其他信息:用户:arn:aws:iam :: [数字]:用户/服务不是 被授权执行:textract:AnalyzeDocument
该用户所在的组附加了AmazonTextractFullAccess策略(arn:aws:iam::aws:policy/AmazonTextractFullAccess
):
(用户的ARN与我的例外中的ARN相匹配,出于隐私原因而被删除)。
我使用适用于.NET的AWS开发工具包。以下是相关代码:
var region = RegionEndpoint.USEast1;
string bucketName = "my bucket's id";
IAmazonS3 s3Client = new AmazonS3Client(region);
GetObjectResponse getObjRespone = s3Client.GetObject(bucketName, "inv.jpg");
using (var ms = new MemoryStream())
{
getObjRespone.ResponseStream.CopyTo(ms);
var textract = new AmazonTextractClient(region);
var request = new AnalyzeDocumentRequest();
var document = new Document();
document.Bytes = ms;
request.Document = document;
AnalyzeDocumentResponse response = textract.AnalyzeDocument(request);
}
我在这里想念什么?
编辑:
使用CLI进行了相同的尝试-此方法有效。我将其配置为使用同一用户。
./aws textract \
analyze-document \
--document '{"S3Object":{"Bucket":"my bucket id","Name":"inv.jpg"}}' \
--feature-types '["TABLES","FORMS"]'