我尝试使用 Agora 的 API 开始云录制,但始终收到“fileNamePrefix 验证失败”错误。这是我当前的设置:
Node.js 环境 Agora 云录音 API v1 用于存储的 AWS S3(区域:ap-south-1)
这是我发送的有效负载:
const start_recording_payoad = {
"uid": user_id.toString(),
"cname": channel_name,
"clientRequest": {
"token": token,
"recordingConfig": {
"maxIdleTime": 30,
"streamTypes": 2,
"channelType": 0,
"videoStreamType": 0,
"transcodingConfig": {
"height": 720,
"width": 1280,
"bitrate": 2000,
"fps": 30,
"mixedVideoLayout": 1,
"backgroundColor": "#000000"
}
},
"recordingFileConfig": {
"avFileType": ["hls", "mp4"]
},
"storageConfig": {
"accessKey": "xxxxxxxx",
"region": 9, // Updated to 9 for ap-south-1
"bucket": "xxxxxx",
"secretKey": "SECRET_KEY_HIDDEN",
"vendor": 2,
"fileNamePrefix": ["partner_live_stream_recording", `${channel_name}`, `${user_id}`]
}
}
};
这是我如何进行 API 调用:
const startResponse = await axios.post(`https://api.agora.io/v1/apps/${appId}/cloud_recording/resourceid/${resource_id}/mode/mix/start`, start_recording_payoad, {
headers: {
'Authorization': authorizationField,
'Content-Type': 'application/json;charset=utf-8'
}
});
我收到的错误是:
Error Response Data: { code: 2, reason: 'start: fileNamePrefix validation failed!' }
我尝试了多种方法来解决这个问题:
我希望 API 调用能够成功启动云录制过程,使用指定的参数创建一个新的录制会话。预期结果是 API 的积极响应,其中包含有关已开始录制会话的详细信息。
相反,我始终收到 fileNamePrefix 验证错误,导致录制无法开始。我不确定 fileNamePrefix 的哪个具体方面导致验证失败,因为错误消息没有提供有关验证失败性质的详细信息。
听起来您遇到的问题是由于文件夹名称中包含特殊字符造成的。删除特殊字符后,问题就解决了。以下是问题和解决方案的摘要:
Problem:
Original folder structure: fileNamePrefix: ["partner_live_stream_recording", ${channel_name}, ${user_id}]
The underscore character (_) in the folder name caused an issue.
Solution:
Updated folder structure: fileNamePrefix: ["partnerivestreamrecording", ${channel_name}, ${user_id}]
Removing the underscore character fixed the issue.