处理程序的主体:
const one: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (event) => {
const input = {
"EndTimestamp": new Date(1653843539000),
"Format": "JPEG",
"ImageSelectorType": "PRODUCER_TIMESTAMP",
"MaxResults": 10,
"SamplingInterval": 3000,
"StartTimestamp": new Date(1653843480000),
"StreamName": "ExampleStream"
}
console.log('input', JSON.stringify(input, null,2))
const client = new KinesisVideoArchivedMediaClient({ region: "eu-central-1" });
const command = new GetImagesCommand(input);
const res = await client.send(command);
console.log('res', JSON.stringify(res, null,2))
return formatJSONResponse({
message: 'success',
event,
});
}当前结果-来自代码的日志:
2022-05-29T17:43:31.063Z 2d#################535 INFO res {
"$metadata": {
"httpStatusCode": 200,
"requestId": "38##################0e",
"attempts": 1,
"totalRetryDelay": 0
}
}预期:响应(包括图像、NextToken属性)
其他详情:
具有从邮递员执行的相同输入的请求给出了正确的响应:
{
"Images": [
{
"Error": "NO_MEDIA",
"ImageContent": null,
"TimeStamp": 1.65384348E9
},
{
"Error": null,
"ImageContent": "/9j/4AAQSkZJRgABAgAAAQABAAD//gARTGF2YzU4LjEzNC4xMDAA/...",
"TimeStamp": 1.653843486E9
}
],
"NextToken": "eyJleHB...n0ifQ=="
}我做错什么了?提前感谢
发布于 2022-05-30 15:34:46
我在使用v3 SDK时遇到了同样的问题,所以我尝试使用v2,没有任何运气,而且数据正在返回任何东西。
但是,我在调用v2之前首先获得了数据端点,从而使它能够与getImages一起工作。
如下所示:
import { KinesisVideo, KinesisVideoArchivedMedia } from 'aws-sdk'
const kinesisVideoClient = new KinesisVideo({
apiVersion: '2017-09-30'
region: process.env.AWS_REGION
})
const { DataEndpoint } = await kinesisVideoClient.getDataEndpoint({ APIName: 'GET_IMAGES', StreamName: 'my-stream' }).promise()
const params = {
StreamName: 'my-stream',
ImageSelectorType: 'PRODUCER_TIMESTAMP',
StartTimestamp: new Date(),
EndTimestamp: new Date(),
SamplingInterval: 3000,
Format: 'JPEG'
}
const options = {
endpoint: DataEndpoint,
apiVersion: '2017-09-30',
region: process.env.AWS_REGION
}
const kinesisVideoArchiveMediaClient = new KinesisVideoArchivedMedia(options)
const { Images } = await kinesisVideoArchiveMediaClient.getImages(params).promise()
console.log(Images)希望这会有所帮助:)
PS。我在Lambda层使用了最新的AWS v2,默认情况下在Lambda上提供的版本没有getImages函数。
https://stackoverflow.com/questions/72426529
复制相似问题