它说我需要首先运行GetDataEndpoint
API才能在运行GetMedia
之前获取端点但是它没有说明如何为该端点提供信息?
所以我试图跑:
import boto3
kinesis_media = boto3.client('kinesis-video-media' region_name='region')
stream = kinesis_media.get_media(StreamARN='my-arn',
StartSelector={'StartSelectorType': 'EARLIEST'}) # this is not the endpoint
然后返回:
ClientError: An error occurred (403) when calling the GetMedia operation: <AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
我猜是没有指定原因端点,但kinesis-video-media
类型的客户端没有获取端点网址所需的get_data_endpoint
方法?
答案 0 :(得分:6)
首先,使用kinesisvideo
客户端获取端点:
import boto3
kinesis_client = boto3.client('kinesisvideo',region_name='us-west-2')
response = kinesis_client.get_data_endpoint(StreamARN='...ARN...',APIName='GET_MEDIA')
response
变量包含:
{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '...', 'HTTPHeaders': {'x-amzn-requestid': '...', 'date': 'Tue, 10 Apr 2018 08:22:59 GMT', 'content-length': '74', 'content-type': 'application/json'}}, u'DataEndpoint': u'https://s-4010cf70.kinesisvideo.us-west-2.amazonaws.com'}
然后,使用给定端点调用kinesis-video-media
客户端:
video_client = boto3.client('kinesis-video-media',endpoint_url='https://s-4010cf70.kinesisvideo.us-west-2.amazonaws.com',region_name='us-west-2')
stream = video_client.get_media(StreamARN='arn:aws:kinesisvideo:us-west-2:...',StartSelector={'StartSelectorType': 'NOW'})
stream
变量包含:
{u'ContentType': 'video/webm', u'Payload': <botocore.response.StreamingBody object at 0x7f1fab294850>, 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '...', 'HTTPHeaders': {'x-amzn-requestid': '...', 'transfer-encoding': 'chunked', 'content-type': 'video/webm', 'date': 'Tue, 10 Apr 2018 08:27:19 GMT'}}}