How to get image from SharePoint document library into thumbnail card of messaging extension of bot framework - botframework

I'm having a SharePoint document library which contains some icons. And i'm having a azure web app bot used for messaging extension using bot framework. In messaging extension preview thumbnail card i need to load the icons from SharePoint library.
Both SharePoint document library and Azure bot are on different tenant and users are also different.
SO when i'm trying to load icons from SharePoint library its giving me unauthorized error due to different tenant and users.
Is there any way to pass base64 string to thumbnail card in to load the image instead of url.
I have tried to convert image from SharePoint document library to base64 string but didn't got a way to pass that base64 string to messaging extension.
I need to show images from sharepoint document library into thumbnail card of bot framework.

There are 2 approaches you can implement.
Store images to Azure blob storage and use static url from the blob. You can use SAS key for security.
Other approach is storing images to SharePoint doc library as you listed in question then you are getting base64 value of image and store that value to a variable and use it in DataUri as below
string.Format("data:image/png;base64,{0}",Convert.ToBase64String(photoBytes));

Related

botframework get attachment api returns with 404 for old images

Background
We are using the following api to fetch image data uploaded from our user via bot.
The API reference is the following.
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#get-attachment
And the use case is the following.
User pasted image along with text and send message to bot.
The following image is the [bot side].
We are fetch the pasted image data and show it on [our app side].
The following is our app side.
Issue
But we found that for the images uploaded [1 month ago], the API returns with 404 http code and we could not get image data anymore.
For the images uploaded recently, The api responsed with 200 and image binary data which we can take usage and show it.
Question
Is it possible that MS side put some restriction for pasted image that uploaded to botframework blob storage more than a month?
It's important to note that the Azure Bot Service's Connector service is not a storage service. When attachments are sent to/thru the Connector, Azure will store the attachment for no more than 24 hours.
If you are needing to access attachments sent days/weeks/months ago, then you should utilize Azure Blob Storage, or some equivalent service, to meet those needs.

how to use azure cognitive search for reading match from web links?

We are working on chatbot using microsoft bot framework. have got a use case to read the content from websites via azure search. Can we use azure search for reading content from websites? can you share any reference url? these websites contains PDF links also , we need to read content from these PDF links also.

Is it possible to serve images from Firebase static hosting?

I have a simple Firebase web application which is hosted on Firebase static hosting service where you can upload a picture with some textboxes and it gets stored in the Firebase realtime database like this:
{
name: string,
description: string,
picData: base64 string
}
Now I would like to serve this image via a HTTP Get request. Is that even possible?
Something like: http://myawesomewebsite.com/getImage?name=x
The same like https://picsum.photos/ does it.
To be able to serve content from the Firebase Realtime Database on a GET request, you will have to extend the functionality of Firebase Hosting using Cloud Functions for Firebase or Cloud Run.
The Connect Functions to Hosting section explains the steps required to serve a "bigben" page that could quickly be adapted to decode the base64 in your database and return the data. Be wary that you must also specify the image's mime type (e.g. image/png, image/jpeg) when serving the image which you don't currently store in your database.
While possible, I would recommend storing your images in Firebase Storage instead. This will help keep track of meta data such as sizes, mime types and upload times whilst not clogging your database with files stored in Base64. Images stored on Firebase storage can also be retrieved via a GET request by the client SDKs or served from a Cloud Function.

Where can I store a user accessible Google Slides template?

I'm currently working on a website which allows reports to be generated and saved as a Google Slide via the Google Slides API. The reports are generated using a template slide which contains placeholder shapes which are then populated with graphs and text.
My problem is that the template Google Slides file needs to be accessible to any user who decides to generate a report. But...
Google Drive can only be authorized via oAuth. Users coming to the site will not be able to authenticate any drive which does not belong to them
The template cannot be stored in the codebase as the slides API is only able to interact with files stored in the cloud AND it is not possible to download a file in 'Google Slides format'
It could be possible to store the template on Google Cloud Storage, but it is not possible to import a Slides file without converting it to another format. Attempting to convert the file once it has been uploaded does not produce a new slides file within the cloud storage
Is there anywhere I could store my Google Slides template and have it accessible to my application at all times so that it may generate reports based on that template?

Set content type of azure blob to image in WP7

I am uploading a stream of photo from my phone camera to azure. I am uploading e.ChosenPhoto which is a stream of the taken photo and i am using blob.Metadata["ImageType"] = "image/jpeg"; but still, when the photo is uploaded the content is marked as application/octet-stream and when i go to the url the browser download the photo instead of displaying it.
What steps do i need to do in order for it to make it jpg ?
EDIT: it seems that the library that comes with WAT for WP - WindowsPhoneCloud.StorageClient.dll
doesn't support blob.Propeties at all. (maybe because WP only support async calls ?) Is there any workaround on setting the content type ?
Try setting blob.Properties.ContentType = "image/jpeg".
Unless the SAS is used, it is highly recommended that we use a cloud service to upload blobs. If we upload a blob directly from Windows Phone without SAS, we have to embed our storage account key in the Windows Phone application. If a hacker gets the key, he will obtain full control of our Windows Azure storage account. For example, he can upload several TB data to the storage, and requires us to pay for the data. So instead of trying to upload the blob from Windows Phone, please try to host a service in Windows Azure. We upload the image to our service, and our service saves the file in blob. As long as we don’t return the storage key in any response, it will be safe.
If we have to upload directly from Windows Phone without SAS, we may need to manually use the REST API for the scenario to work. According to http://watwp.codeplex.com/discussions/352111 , the WAT library doesn’t allow us to specify a content type. In addition, I would like to point out that WAT is just a toolkit. It is not a built-in Windows Azure component.
Best Regards,
Ming Xu.

Resources