2016-08-14 118 views
0

所以我有第一个运行对话框要求用户上传照片。我通过这样做:使用Node.js显示图像Microsoft Bot Framework

builder.Prompts.attachment(session, "Thanks. Now upload a picture").

,然后在瀑布下一部分,保存上传媒体session.userData像这样:

function(session, results) { 
    //some other code 
    builder.Prompts.attachment(session, "Thanks. Now upload a picture."); 
}, 
function(session, results) { 
    session.userData.profilePhoto = results.response; 
    session.endDialog("All done.") 
} 

所以说我也知道要显示的照片。我会怎么做?

我试图发送一个HeroCardCardImage

var message = new builder.Message(session); 

var att = new builder.HeroCard(session) 
     .images([ 
      builder.CardImage.create(session, session.userData.profilePhoto) 
     ]) 
     .buttons([ 
      builder.CardAction.openUrl(session, "http://google.com", "buttonText") 
     ]); 

message.addAttachment(att); 
session.send(message) 

,但没有工作(我也试图为CardImage但没有工作做session.userData.profilePhoto.contentUrl以及)。

我想如何显示图像?

回答

1

UserData不是用来存储大对象,只是状态。数据包仅限于64k。您需要使用自己的存储机制来存储图像。

+0

好的,但即使如此,我将如何显示这些存储的图像?我是否需要将它们存储在某种类型的数据库中,该数据库提供了一个URL并将其传递到'CardImage'中? Node.js文档目前没有写在图像上的指南,所以我正在寻找一些关于使用我的机器人显示图像的一般信息。 – Orbit

+0

Azure Blog Storage有一个非常简单的node.js库。 https://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-blob-storage/ – Lars

+0

我会看看它,谢谢。 – Orbit

相关问题