Receiving image from Microsoft Graph Api - asp.net-core

Im trying to get at photo from an azure ad using microsoft graph api.
I make the request to api. I know the uri is correct. When i try it with correct security token in Postman the photo is displayed. When i try the same uri in microsofts graph explorer online i as well see the image. When i look at the sourcode i can see an image tag with the followin src
<img src="blob:https://developer.microsoft.com/xxxxx-xxxx-xxx-xxxx-xxxxxxxx">
But when i make the call from a net core 2 backend i cant manage to get anything usefull. Im not sure what im supposed to use to receive the blob or how to handle the blob. How do i receive a blob from microsoft graph api?

The Graph explorer converts the API response to a blob. This blob object has a URL that can be the src attribute of an <img> tag.
Graph explorer is open source and if you know a bit of javascript this might be an example worth looking at. We convert the Graph API response to a blob at https://github.com/microsoftgraph/microsoft-graph-explorer/blob/e2a376615d14c5eabd51e972478b18827800d323/src/app/query-runner.service.ts#L116
For asp .net core, maybe look at the aspnetcore-connect-sample? They convert the photo response to base64 at https://github.com/microsoftgraph/aspnetcore-connect-sample/blob/41e6cfeae6d6fb0035a188f066d56de1ad697841/MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphService.cs#L54

Related

React Native Axios and ngrok Error on Get returning hyperlink

I am working on a simple application composed of React Native for my front end and React Express for my API. I am storing images on AWS S3. Uploading images works, and downloading images kind of works.
Postman Get Call on Image using Image Key
As you can see in the link above, when I test the download, it gives me a signed URL which is live for 15 minutes which I can access. The idea is to pass that as my URI to my Image component.
However, when I try to do the same exact thing from my front end using Axios (the API is not deployed, and I am using ngrok to tunnel into it for local easy testing), this is what I get:
Front End Get Call on Image using Image Key
When I attempt to decode the base64 payload string, it is simply restating what the top half of the image says. This issue doesn't occur with many of my other API calls from my front-end through ngrok. I am able to have authorization mechanics, group mechanics, and even OCR functionality via API calls.
Is it because it is returning a hyperlink? Is there a way to return it as simply a string? This is new territory for me. I am using aws-sdk/clients/s3 library and using getSignedUrl, and passing the return of that back via res.status(200).send(signedUrl).
Thank you for reading.

How do I Automate BIng Maps data upload?

How do I upload data to Bing Maps without having to use the portal? I can’t find anything in the documentation that mentions this, but any time we update our data, I have to manually upload a new XML file. Ideally, we would automate the upload whenever we update the data.
The closest I can get is the Uploading Data page, but there's nothing there about it.
Use the data source management API: https://learn.microsoft.com/en-us/bingmaps/spatial-data-services/data-source-management-api/
If you are working in .NET, you might also find this library useful: https://github.com/Microsoft/BingMapsSDSToolkit

Vimeo Upload API

I'm trying to upload videos to my Vimeo account via their API using the TUS approach.
I've managed to get the first step working fine, using POST https://api.vimeo.com/me/videos to create the video placeholder in Vimeo, and getting a response which includes the video upload.upload_link
The second step requires the binary data of the video to be patched to the upload link returned in step one using PATCH{upload.upload_link} along with some specific headers, which is fine, but what I'm struggling to work out is where and how exactly to include the binary data, as it doesn't really say in the Vimeo API documentation.
Do I just put the binary data in the Body, on it's own? Or do I need to insert it between some code in the body? Or do I set a parameter and add it as a key value, and if so what is the key?
Also, I'm assuming it should be a binary string and not base64, is that correct?
Any help or guidance on this would be much appreciated.
You put the binary data directly in the request body. Vimeo API uploading uses the tus upload protocol. There is more information about the PATCH request at https://tus.io/protocols/resumable-upload.html#patch

Can I use Autodesk viewing API to render local DWG (2D) files to my browser?

The main goal of my project is to read Autocad(DWG) drawings from my local server to output them in a web browser (Chrome).
I managed to do it with the View and Data API in JAVA from Autocad with buckets, Key, etc. but when it comes to read offline files with this sample code from https://github.com/Developer-Autodesk/view-and-data-offline-sample, the DWG format did not work.
Do you have suggestion or have a clue to use the offline API with DWG files?
The Autodesk View & Data API (developer.autodesk.com) allows you to display a DWG on your website using a zero-client (WebGL) viewer. You need to upload the DWG to the Autodesk server, translate it, and either then download the translation to store on your local server (as demonstrated on extract.autodesk.io) or keep it on the Autodesk server. You might consider downloading it to be advantageous because then you don't need to implement the OAuth code on your server.
Buckets on the Autodesk server can only be accessed using the accesstoken created from your API keys, so it is secure in that only someone with your accesstoken and who knows the URN can access your translated file. However, for the viewer on your client-page to access the file, you need to provide it with your accesstoken. This does mean that someone could separately access your translated file by grabbing the accesstoken and URN from your webpage. But if you're serving up the model on a public page, then you presumably don't care about that.
There is a 'list' API available, but this is white-listed (available on request), so getting your accesstoken and urn for one file doesn't automatically give access to your other files - unless someone can guess the other filenames (or iterate to find them).
If you use a non-permanent bucket, then your original (untranslated file) becomes unavailable when the bucket expires, or you can explicitly delete the untranslated file (using the delete API).
Files translated via the View & Data API are not accessible via A360. They are stored in a separate area. (But I wouldn't be at all surprised if an A360 file access API became available in the near future :-).
Finally, unless you want to interact with the displayed file via the viewer's JavaScript API, you may prefer just to upload your files to A360, share the translated model, and then iframe embed them in your webpage.

How to delete an image on Imageshack using its API

I'm trying to use the Imageshack api to delete an image uploaded to my account.
I have successfully managed to upload an image to it using the API.
https://www.imageshack.us/upload_api.php?url=[URL_OF_THE_IMAGE]&key=[MY_KEY]
I can delete the image uploaded by using the standard interface.
Any solution using the API?
I have managed it by doing the following:
First log in to get an auth_token:
HTTP POST
https://api.imageshack.us/v1/user/login?username=YOUR_USERNAME&password=YOUR_PASSWORD
Parse "auth_token" from the response
Then delete:
HTTP DELETE
https://api.imageshack.us/v1/images/SERVER/FILENAME?auth_token=AUTHTOKEN
In addition to AUTHTOKEN you need include SERVER and FILENAME, I store these from files.server and files.image.filename that come back in the response to the upload API call.
Jamie Clark's solution is what you need, using the proper v1 api. Your sample script is still using the posting methodology from their older API as described here. That one doesn't expose any deletion methods. What Jamie is describing is the API as it is currently, documented here. It's not clear if the API keys are the same, but I'm guessing no - my new one doesn't seem to work with this old call and the link from that google code page for requesting an API key is defunct.