c# - Upload image to Skype BOT -
i have bot develop microsoft bot framework, , in debug run correctly
after install on skype, after upload image have link this
https://df-apis.skype.com/v2/attachments/0-eus-d4-7e19a097c62f5fc21dd53eabfa19d85e/views/original
the code , run without skype
if ((activity.attachments != null) && (activity.attachments.count > 0)) { analysisresult = await analyzeurl(activity.attachments[0].contenturl); } ........
how find picture sent?
according this comment, fetch attachment, request should contain jwttoken of bot authorization header:
var attachment = activity.attachments?.firstordefault(); if (attachment?.contenturl != null) { using (var connectorclient = new connectorclient(new uri(activity.serviceurl))) { var token = await (connectorclient.credentials microsoftappcredentials).gettokenasync(); var uri = new uri(attachment.contenturl); using (var httpclient = new httpclient()) { if (uri.host.endswith("skype.com") && uri.scheme == uri.urischemehttps) { httpclient.defaultrequestheaders.authorization = new authenticationheadervalue("bearer", token); httpclient.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/octet-stream")); } else { httpclient.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue(attachment.contenttype)); } var attachmentdata = await httpclient.getbytearrayasync(uri); analysisresult = await analyzeurl(attachmentdata); } } }
that means have change analyzeurl
accept image data instead of url. believe cognitiveservices, using, able accept image data.
Comments
Post a Comment