【发布时间】:2020-11-24 15:53:39
【问题描述】:
我有这个昨天有效的代码。它对视频文件上传的简单请求,验证文件是否为视频格式,然后保存。
视频提示是
var promptOptions = {
prompt: 'Upload a video',
retryPrompt: 'The attachment must be a video file.'
};
return await step.prompt(VID_PROMPT, promptOptions);
其中 VID_PROMPT 是一个 AttachmentPrompt:
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 将是错误的,因此在我的 videoValidator 中执行 else 子句。
现在,我尝试上传图片,只是为了检查它是否会识别附件文件类型:
并且消息附件必须是视频文件。当它识别出我上传了附件但文件类型不是视频时显示。这是后面的数据:
我该如何解决这个问题。我没有改变任何东西,只是突然没有工作。请帮忙。谢谢!
PS。我使用 botbuilder 4.11.0。
更新:我检查了直连频道及其工作正常。我猜它在 Facebook 频道上不起作用?
更新:现在,即使图像也不会被识别为附件 :(
【问题讨论】:
标签: botframework facebook-messenger facebook-messenger-bot