簡體   English   中英

Amazon Kinesis視頻GetMedia / PutMedia

[英]Amazon Kinesis Video GetMedia/PutMedia

我使用python 3.6,我想使用API​​將視頻流發布到aws kinesis。 我使用python aws客戶端創建流和GetDataEndPoint但是當我想用自定義請求發布數據時( PutMedia實際上不包含在python客戶端中),我收到錯誤消息, Unable to determine service/operation name to be authorized

我遵循aws kinesis視頻媒體PutMediaGetMedia的api文檔。

因此,我首先使用客戶端方法通過GetDataEndPoint獲取端點:

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

然后將數據發布到以下網址:

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參數。 我所做的...

如果未正確指定端點,則可能會發生此錯誤。 獲取端點時,請確保在GetDataEndpoint調用中包括以下參數,具體取決於要調用的API:

我也想知道GetMedia方法是否實際上在客戶端中實現了,因為他們在這里因為在調試此方法時,客戶端不會調用GetDataEndPoint並因此在https://kinesisvideo.region.amazonaws.com發出請求,而使用https://ID_EXAMPLE.kinesisvideo.region.amazonaws.com 因此方法出現錯誤Unable to determine service/operation name to be authorized按照故障排除中的說明Unable to determine service/operation name to be authorized

您得到的錯誤是因為您提供的端點可能沒有在您的情況下為putMedia的“操作”。

嘗試將/putMedia附加到端點,不要忘記指定"content-type": "application/json"標頭。

此外,您還必須為您的請求生成v4簽名 您可以使用lib或按照此python指南進行操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM