本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
通过 CLI 进行处理
将文件输入到 S3 存储桶
使用 BDA 处理文档之前,您必须先将文档上传到 S3 存储桶:
语法
aws s3 cp <source> <target> [--options]
示例:
aws s3 cp /local/path/document.pdf s3://my-bda-bucket/input/document.pdf
- Async
-
基本处理命令结构
使用
invoke-data-automation-async命令处理文件:aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg" }' \ --output-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"高级处理命令结构
使用时间段的视频处理
对于视频文件,您可以指定要处理的时间段:
aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/video.mp4", "assetProcessingConfiguration": { "video": { "segmentConfiguration": { "timestampSegment": { "startTimeMillis": 0, "endTimeMillis": 300000 } } } } }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"使用自定义蓝图
您可以直接在命令中指定自定义蓝图:
aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --blueprints '[ { "blueprintArn": "Amazon Resource Name (ARN)", "version": "1", "stage": "LIVE" } ]' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"添加加密配置
为了增强安全性,您可以添加加密配置:
aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --encryption-configuration '{ "kmsKeyId": "Amazon Resource Name (ARN)", "kmsEncryptionContext": { "Department": "Finance", "Project": "DocumentProcessing" } }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"事件通知
启用处理完成 EventBridge 通知:
aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --notification-configuration '{ "eventBridgeConfiguration": { "eventBridgeEnabled": true } }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"检查处理状态
使用
get-data-automation-status命令检查您的处理作业的状态:aws bedrock-data-automation-runtime get-data-automation-status \ --invocation-arn "Amazon Resource Name (ARN)"响应将包括当前状态:
{ "status": "COMPLETED", "creationTime": "2025-07-24T12:34:56.789Z", "lastModifiedTime": "2025-07-24T12:45:12.345Z", "outputLocation": "s3://my-bucket/output/abcd1234/" }检索处理结果
在 S3 中查找输出文件
列出 S3 存储桶中的输出文件:
aws s3 ls s3://amzn-s3-demo-bucket/output/将结果下载到本地计算机:
aws s3 cp s3://amzn-s3-demo-bucket/output/ ~/Downloads/bda-results/ --recursive了解输出结构
输出通常包括:
-
standard-output.json:包含标准提取结果 -
custom-output.json:包含来自自定义蓝图的结果 -
metadata.json:包含处理元数据和置信度分数
常见的响应字段
标准输出通常包括:
-
extractedData:主要提取的信息 -
confidence:提取的每个字段的置信度分数 -
metadata:处理信息,包括时间戳和模型详细信息 -
boundingBoxes:检测到的元素的位置信息(如果启用)
错误处理和故障排除
常见的错误场景和解决方案:
-
S3 URI 无效:确保您的 S3 存储桶存在并且您拥有适当的权限
-
缺失 data-automation-profile-arn:所有处理请求都需要此参数
-
未找到项目:确保您的项目 ARN 正确并且项目存在
-
不支持的文件格式:检查 BDA 是否支持您的文件格式
为处理任务添加标签
您可以添加标签来帮助整理和跟踪处理作业:
aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --tags '[ { "key": "Department", "value": "Finance" }, { "key": "Project", "value": "InvoiceProcessing" } ]' \ --data-automation-profile-arn "Amazon Resource Name (ARN)" -
- Sync
-
基本处理命令结构
使用
invoke-data-automation命令处理文件:aws bedrock-data-automation-runtime invoke-data-automation \ --input-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)" --region "aws-region"高级处理命令结构
输出到 S3 存储桶
aws bedrock-data-automation-runtime invoke-data-automation \ --input-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg" }' \ --output-configuration '{"s3Uri": "s3://amzn-s3-demo-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)" --region "aws-region" //document only使用字节输入
aws bedrock-data-automation-runtime invoke-data-automation \ --input-configuration '{ "bytes": #blob input }' \ --output-configuration '{"s3Uri": "s3://amzn-s3-demo-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)" --region "aws-region"注意
字节
一组 base64 编码的文档字节。以 blob 字节形式提供的文档的最大大小为 50 MB。类型应为 Base64 编码的二进制数据对象。
使用自定义蓝图(仅适用于图像)
aws bedrock-data-automation-runtime invoke-data-automation \ --input-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg" }' \ --blueprints '[{"blueprintArn": "Amazon Resource Name (ARN)", "version": "1", "stage": "LIVE" } ]' \ --data-automation-profile-arn "Amazon Resource Name (ARN)" --region "aws-region"