视频上传未被确认为 Bot Framework SDK 4 中的附件
Video upload is not being acknowledge as an attachment in Bot Framework SDK 4
我有这个代码昨天可以用。简单的视频文件上传请求,验证文件是否为视频格式,然后保存。
视频提示为
var promptOptions = {
prompt: 'Upload a video',
retryPrompt: 'The attachment must be a video file.'
};
return await step.prompt(VID_PROMPT, promptOptions);
其中 VID_PROMPT 是附件提示:
this.addDialog(new AttachmentPrompt(VID_PROMPT, this.videoValidator));
和验证器,videoValidator的代码是:
async videoValidator(promptContext) {
//for back end cheking
console.log("\n\r Message Type:" + promptContext.context._activity.type);
console.log("\n\r Message:" + JSON.stringify(promptContext.context._activity.channelData.message));
/***************************/
if (promptContext.recognized.succeeded) {
var attachments = promptContext.recognized.value;
var validImages = [];
attachments.forEach(attachment => {
if (attachment.contentType === 'video/mp4' || attachment.contentType === 'video/x-msvideo' || attachment.contentType === 'video/mpeg' || attachment.contentType === 'video/3gpp' || attachment.contentType === 'video/3gpp2') {
validImages.push(attachment);
}
});
promptContext.recognized.value = validImages;
// If none of the attachments are valid videos, the retry prompt should be sent.
return !!validImages.length;
}
else {
await promptContext.context.sendActivity('No attachments received. Please attach video file.');
return false;
}
}
同样,昨天它运行良好(使用相同的代码)但是今天,每当我上传视频时:
会提示没有收到附件。请附上来自我的验证器的视频文件
所以我看了看后面,看到了这个:
这表示收到的消息不包含附件,当然 AttachmentPrompt 会看到这个并且 promptContext.recognized.succeeded 将是 false 从而在我的 videoValidator[= 中执行 else 子句52=].
现在,我尝试上传图片,只是为了检查它是否能识别附件文件类型:
消息附件必须是视频文件。 当它识别出我上传了附件但文件类型不是视频时显示。这是后台数据:
我该如何解决这个问题。我没有改变任何东西,只是突然不起作用。请帮忙。谢谢!
PS。我使用 botbuilder 4.11.0.
更新:我检查了直线频道,它工作正常。我猜它只是在 Facebook 频道上不起作用?
更新:现在,即使是图片也不会被识别为附件:(
此问题与 FB webhook 相关(并且正在处理)请参阅此线程:https://developers.facebook.com/support/bugs/393441492018560/
我有这个代码昨天可以用。简单的视频文件上传请求,验证文件是否为视频格式,然后保存。
视频提示为
var promptOptions = {
prompt: 'Upload a video',
retryPrompt: 'The attachment must be a video file.'
};
return await step.prompt(VID_PROMPT, promptOptions);
其中 VID_PROMPT 是附件提示:
this.addDialog(new AttachmentPrompt(VID_PROMPT, this.videoValidator));
和验证器,videoValidator的代码是:
async videoValidator(promptContext) {
//for back end cheking
console.log("\n\r Message Type:" + promptContext.context._activity.type);
console.log("\n\r Message:" + JSON.stringify(promptContext.context._activity.channelData.message));
/***************************/
if (promptContext.recognized.succeeded) {
var attachments = promptContext.recognized.value;
var validImages = [];
attachments.forEach(attachment => {
if (attachment.contentType === 'video/mp4' || attachment.contentType === 'video/x-msvideo' || attachment.contentType === 'video/mpeg' || attachment.contentType === 'video/3gpp' || attachment.contentType === 'video/3gpp2') {
validImages.push(attachment);
}
});
promptContext.recognized.value = validImages;
// If none of the attachments are valid videos, the retry prompt should be sent.
return !!validImages.length;
}
else {
await promptContext.context.sendActivity('No attachments received. Please attach video file.');
return false;
}
}
同样,昨天它运行良好(使用相同的代码)但是今天,每当我上传视频时:
会提示没有收到附件。请附上来自我的验证器的视频文件 所以我看了看后面,看到了这个:
这表示收到的消息不包含附件,当然 AttachmentPrompt 会看到这个并且 promptContext.recognized.succeeded 将是 false 从而在我的 videoValidator[= 中执行 else 子句52=].
现在,我尝试上传图片,只是为了检查它是否能识别附件文件类型:
消息附件必须是视频文件。 当它识别出我上传了附件但文件类型不是视频时显示。这是后台数据:
我该如何解决这个问题。我没有改变任何东西,只是突然不起作用。请帮忙。谢谢!
PS。我使用 botbuilder 4.11.0.
更新:我检查了直线频道,它工作正常。我猜它只是在 Facebook 频道上不起作用?
更新:现在,即使是图片也不会被识别为附件:(
此问题与 FB webhook 相关(并且正在处理)请参阅此线程:https://developers.facebook.com/support/bugs/393441492018560/