亚马逊 Kinesis Video GetMedia/PutMedia [英] Amazon Kinesis Video GetMedia/PutMedia

查看:29
本文介绍了亚马逊 Kinesis Video GetMedia/PutMedia的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 python 3.6,我想使用 API 将视频流发布到 aws kinesis.我使用 python aws 客户端创建流和 GetDataEndPoint 但是当我想用我的自定义请求发布我的数据时(PutMedia 实际上不包含在 python 客户端中),我得到错误无法确定要授权的服务/操作名称.

I used python 3.6 and I want to post video stream to aws kinesis with API. I used python aws client to create stream and GetDataEndPoint but when I want to post my data with my custom request (PutMedia doesn't include in python client actually), I get an error Unable to determine service/operation name to be authorized.

我遵循了 aws kinesis 视频媒体的 api 文档 PutMediaGetMedia.

I've follow the api doc of aws kinesis video media PutMedia and GetMedia.

所以我首先使用 GetDataEndPoint客户端方法:

So I start by getting endpoint with GetDataEndPoint with client method:

response = client.get_data_endpoint(  # aws client method
    StreamName=STREAM_NAME,
    APIName='PUT_MEDIA'
)
end_point = response['DataEndpoint'] # https://s-EXAMPLE.kinesisvideo.eu-west-1.amazonaws.com

我在这个网址发布我的数据:

and I post my data at this url:

headers = {
    "x-amzn-stream-arn": STREAM_ARN,
    "x-amzn-fragment-timecode-type": "ABSOLUTE",
    "x-amzn-producer-start-timestamp": start_tmstp
}
# Sign header...
response = requests.post(end_point, data=data, headers=headers)  # 403 - Unable to determine service/operation name to be authorized

所以我不明白为什么我会收到这个错误......我发现了这个故障排除 在 aws 文档上.但是他们说我们必须指定 ApiName 参数.我做什么...

So I don't understand why I get this error... I've found this troubleshooting on aws doc. But they say we must specify ApiName parameter. What I do...

如果未正确指定端点,则可能会发生此错误.获取端点时,请务必在 GetDataEndpoint 调用中包含以下参数,具体取决于要调用的 API:

This error might occur if the endpoint is not properly specified. When you are getting the endpoint, be sure to include the following parameter in the GetDataEndpoint call, depending on the API to be called:

我还想知道 GetMedia 方法是否真的像他们所说的那样在客户端中实现了这里 因为当我调试这个方法时,客户端不调用 GetDataEndPoint 并因此提出请求在 https://kinesisvideo.region.amazonaws.com 代替 https://ID_EXAMPLE.kinesisvideo.region.amazonaws.com.因此方法得到错误无法确定要授权的服务/操作名称,如疑难解答

I'm also wondering if the GetMedia method is actually implemented in client as they say here because when I debug this method, client don't call GetDataEndPoint and so make request at https://kinesisvideo.region.amazonaws.com insteed of https://ID_EXAMPLE.kinesisvideo.region.amazonaws.com. So method get error Unable to determine service/operation name to be authorized as explained in troubleshooting

推荐答案

你得到的错误是因为你可能提供了没有action"的端点,在你的情况下是 putMedia.

The error you're getting is because you're probably providing the endpoint without the "action" that in your case would be putMedia.

尝试将 /putMedia 附加到您的端点,不要忘记指定 "content-type": "application/json" 标头.

Try to append /putMedia to your endpoint and don't forget to specify the "content-type": "application/json" header.

顺便说一句,您还必须生成 v4 签名 用于您的请求.您可以使用 lib 或遵循此 python 指南 去做.

Btw you have also to generate the v4 signatures for your request. You can use a lib or follow this python guide to do it.

这篇关于亚马逊 Kinesis Video GetMedia/PutMedia的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆