1

I am building on bot application where i need to show images in Carousel, I am using Hero card. In this card i need to show image which i am getting from API, image data is in byte format and in herocard it is asking for URI cant we pass byte data in Herocard?

  allAttachements.Add(new HeroCard
            {
                Title = "test" ,
                Subtitle = "SubTitle",
                Text = "Details",
                Images = new List<CardImage> { new CardImage(url) },
            })
             }.ToAttachment()

            );

I tried with below line but it wont work.

string url = $"data:image/png;base64,{ImageData}";

Appreciate your help in advance.

Riyaj Shaikh
  • 108
  • 7

2 Answers2

0

Please try this:

reply.Attachments.Add(new Attachment()
{
     ContentUrl = $"data:image/jpeg;base64,{Convert.ToBase64String(candidate.ImageData)}"
})
D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34
  • Please do not duplicate answers. Look first for duplicates and flag the question instead of adding the same answer. – Ezequiel Jadib Sep 11 '17 at 18:24
  • Hey @JasonSowers, i have Multiple Herocards and i am passing multiple cards as attachment hero card – Riyaj Shaikh Sep 11 '17 at 18:25
  • @EzequielJadib didn't know that existed. You should be able to repurpose this code, or the code in Ezequiel's duplicate for your needs. really all that is missing is the `Convert.ToBase64String(candidate.ImageData)` – D4RKCIDE Sep 11 '17 at 18:31
0

It was my bad i was passing "data:image/png;base64", 2 times thats why image is not showing, now image is visible. thanks @JasonSowers @EzequielJadib for your reply

Riyaj Shaikh
  • 108
  • 7