I am trying to embed a document from Office 365 in a webpage. Currently I am attempting to do this using a DriveItem I have retrieve through Microsoft Graph in an iframe.
This question was asked previously, here. The suggested method was to put the webUrl from the DriveItem, however when I attempt this I see the webUrl is returning a x-frame-options: SAMEORIGIN header, and so the iframe is blocked from displaying it.
The alternative solution appears to be using the #microsoft.graph.downloadUrl. However, when I place this in a iframe, the file is downloaded in my browser, not embedded.
I also investigated getting an embed-able link, however it appears these links for DriveItems are only available for OneDrive personal. I need a solution for OneDrive for Business.
Related
I am using microsoft teams API to fetch public channel message. With messages I also get attachments with a sharepoint URL as content URL. Now I want to download that file but it fails to download it. If I directly copy paste contentURL on browser, it downloads the file but if I do an http call, it fails. I cannot use sharepoint graph api(download by item ID) as I don't get itemID here. Is there any way to download those file? Any permission needed or any mistake I am doing on HTTP call?
PS: I do see a couple of same questions but there are no accepted answer and all are couple of years old.
How do I send HTML content from OneDrive Graph Api /sendMail endpoint? I have tried various permutations of HTML and encoded HTML in the body but I never receive HTML in the actual email.
-- Edit --
It turns out my problem is actually Outlook Online stripping unsafe HTML. If I include a link to Bing.com that gets stripped, if I include a link copied from one of my automated Teams emails that does not get stripped.
I have trawled the Office 365 Security and Compliance but found nothing to flag specific domains as safe.
If anyone knows how to mark domains as safe, or some other solution that would be great.
Using createLink, for example with the POST parameters: {"type": "view", "scope": "anonymous"}, you get a response including a webUrl which will open the item (in read-only or read-write mode, depending on the POST parameters) in Office Online. Because of the 'anonymous' scope, anyone (no login required) can open the office online page.
Unfortunately, I don't a link to Office Online, and it looks like this is the functionality provided by Create a sharing link for a DriveItem.
I need a link to the actual file (to download it).
Something like many other 'files' APIs allow. This is, generate a time-limited (or permanent) URL to file.
Is this possible?
EDIT: Clarification: Download the contents of a DriveItem (i.e. a Stream) is not what I'm looking for.
There are four ways of linking to a file in OneDrive via Microsoft Graph:
The web preview for the file, which is accessed from the webUrl property of DriveItem. This requires the user to be signed in to access.
The WebDAV URL for the file, which is accessed from the webDavUrl property of DriveItem. This also requires the user to be signed in to access, but is a direct link to the file. Note: this is available via Microsoft Graph, but is only documented on dev.onedrive.com.
Creating a sharing link, which provides anonymous or organization restricted access to the web preview of the file.
Download link, which is a short-duration URL available to download the contents of the file programmatically.
It sounds like webDavUrl might be the link you are looking for.
I'm experimenting with the Mendeley API to upload and retrieve documents and files and have a problem with the files/{file_id} endpoint.
I have a personal Mendeley account I'm using for testing, populated with some PDF documents.
For example, on the API documentation page if I call
GET /files
I see all the files I've added, but if I take an id value, then call
GET /files/{file_id}
using the ID, e.g.
https://api.mendeley.com:443/files/7b188de2-32a7-f067-51bd-520179e866b8
I get a strange response code of 0, response headers is {}, response body is 'no content'. This happens with all the ids from the file listing - is this a bug or am I doing something wrong?
If I alter the id string, I get a 404 Not found error, which is to be expected, so it's not an authorisation or other general issue.
It's a limitation of Swagger, the software that's used to run the API documentation web page.
That endpoint returns a redirect to an S3 download URL, to allow you to grab the file. Unfortunately Swagger doesn't handle the redirect properly, and it shows it as a response code of 0.
The endpoint is working correctly; it's just not displaying properly on the documentation page.
If I embed a Youtube video on my web page, what are the data usage implications on my server?
I have a shared web hosting plan for my website with a data transfer limit of 5 GB/month. When a user plays video on my site, is my server taxed for data transfer i.e. if the video is of size 1GB, is my data transfer limit decreased by 1GB?
And is my server processor taxed for video streaming?
What other things should I be concerned about?
Is there any link you can point me towards? That will be helpful.
Thanks
Both the youtube player and the video content is streamed from Youtube's server. The only price you pay is the few bytes it takes to add the video player embed code in your HTML pages.
When you embed a YouTube video, it streams directly from YouTube's servers.
Your server is not involved.
When you insert youtube or any embed code in your html page, your server serves the html content to the user's web browser / client (technically means user's web browser). And this html content is processed and translated by the client/ user's web browser. This means that it is served by your server as a link, but when the client translates it, it becomes an action; an action to pull content from the somewhere. So the client (user's web browser pulls the video from the specified url embedded in the iframe. In turn, the bandwith been used are calculated from
In addition to what Etienne Perot said,
There are 3 nodes in play here, namely:
Your server
Youtube Servers
The Client (i.e the user accessing you website)
In simple words: embed is an html tag that allows you include a link to a resource. And since youtube's embed goes in the form of youtu.be/foo or youtube.com/foo. Your browser simply parses (processes the link) and gets the content from that link, thereby visiting youtube website (underground) to fetch the referenced link without going through your server nor anything like that.
Meanwhile when you insert youtube or any embed code in your html page, your server serves the html content to the visitor's web browser / client (technically means visitor's web browser). And this html content is processed and translated by the client / user's web browser.
This means that it is served by your server as a link, but when the client translates it, it becomes an action; an action to pull content from the somewhere. So the client (user's web browser pulls the video from the specified url embedded in the iframe.
In turn, the bandwith been used are calculated from
The client (i.e the bandwidth used to access in the internet and the video's url) - calculated or billed by your ISP from your data active subscription.
Youtube's Server (i.e the bandwidth from the server that serves the content being streamed) - calculated or billed by google cloud service from their inhouse cloud resource allocation.
If you use the google chrome browser, you can check this our by right clicking on the video and clicking inspect element, then switching to the network tab; you might have to hit refresh so that the page tries to get all the content loaded all over again: the purpose of this is to see where the content is loaded from.
See Network Analysis Reference on how to use the network tab in google chrome developer tools. Mozilla firefox and some named browsers also have the inspect element and network monitor feature.
I hope this helps somebody.