如何使用 Microsoft Graph API 获取 OneDrive 中文件的临时(或永久)常规 URL [英] How to get a temporary (or permanent) regular URL for a file in OneDrive using the Microsoft Graph API

查看:95
本文介绍了如何使用 Microsoft Graph API 获取 OneDrive 中文件的临时(或永久)常规 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 createLink,对于带有 POST 参数的示例:{"type": "view", "scope": "anonymous"},您会收到一个包含 webUrl 的响应,它将打开项目(以只读或只读方式)-write 模式,取决于 POST 参数)在 Office Online 中.由于匿名"范围,任何人(无需登录)都可以打开办公室在线页面.

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.

不幸的是,我没有指向 Office Online 的链接,看起来这是 为 DriveItem 创建共享链接.

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.

我需要一个指向实际文件的链接(以下载它).类似于许多其他文件"API 允许的东西.也就是说,生成一个限时(或永久)的文件 URL.

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.

这可能吗?

澄清:下载内容DriveItem(即流)不是我要找的.

Clarification: Download the contents of a DriveItem (i.e. a Stream) is not what I'm looking for.

推荐答案

有四种方式可以通过 Microsoft Graph 链接到 OneDrive 中的文件:

There are four ways of linking to a file in OneDrive via Microsoft Graph:

  • 文件的网络预览,可从 DriveItem 的 webUrl 属性访问.这需要用户登录才能访问.
  • 文件的 WebDAV URL,可从 DriveItem 的 webDavUrl 属性访问.这也需要用户登录才能访问,但它是指向文件的直接链接.注意:这可通过 Microsoft Graph 获得,但仅记录在 dev.onedrive.com.
  • 创建共享链接,它提供对文件的网络预览的匿名或组织受限访问.
  • 下载链接,其中是可用于以编程方式下载文件内容的短期 URL.
  • 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.

听起来 webDavUrl 可能就是您要查找的链接.

It sounds like webDavUrl might be the link you are looking for.

这篇关于如何使用 Microsoft Graph API 获取 OneDrive 中文件的临时(或永久)常规 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆