OneDrive 文件存储 API 概述OneDrive file storage API overview

OneDrive 是 Office 365 的文件中心。OneDrive is the files hub in Office 365. 人们会在各种各样的环境中使用文件,如 Microsoft Teams、组、SharePoint 等。People work with files in a variety of contexts, like Microsoft Teams, groups, SharePoint, and more. 通过 OneDrive,用户可以访问这些文件而不管它们存储在什么位置,而通过 Microsoft Graph,则可以使用单个 API 来使用它们。With OneDrive, users can access these files no matter where they are stored, and with Microsoft Graph, you can use a single API to work with them.

Office 365 中的文件存储在驱动器中。Files in Office 365 are stored in drives. 用户可以在其个人驱动器 (OneDrive) 或 SharePoint 文档库支持的共享驱动器中存储文件。Users can store files in a personal drive - their OneDrive - or in a shared drive powered by a SharePoint document library. 但是 OneDrive 的灵活性可使用户以最佳的方式进行协作。OneDrive's flexibility lets users collaborate however it works best for them. 用户可以共享文件链接、将文件复制或移动到团队驱动器,甚至可以将 OneDrive 文件附加到 Outlook 中的邮件消息。Users can share links to files, copy or move files to team drives, or even attach OneDrive files to mail messages in Outlook.

为什么与云中的 OneDrive 文件存储集成?Why integrate with OneDrive file storage in the cloud?

利用一个包含数十亿个文件的生态系统Tap into an ecosystem with billions of files

OneDrive 用户可从任何设备以联机或脱机方式访问他们的文件,并与其组织内外人员共享文件。OneDrive users can access their files from any device, online or offline, and share files with people inside or outside their organization. OneDrive 可以在 Word、Excel 和 PowerPoint 等熟悉的应用中实现实时共同创作功能。OneDrive enables real-time coauthoring in familiar apps like Word, Excel, and PowerPoint. 通过 Microsoft Graph 提供支持的数百种格式、视频流、分析等丰富的缩略图呈现文件。Files light up with rich thumbnails for hundreds of formats, video streaming, analytics, and more, powered by Microsoft Graph. OneDrive 中的数据受到客户信任的高级加密、合规性和安全性功能的保护。Data in OneDrive is protected with advanced encryption, compliance, and security features that customers trust.

有超过 5 亿的设备运行 OneDrive 应用,超过 85% 的财富 500 强企业使用 OneDrive for Business,通过将应用与 OneDrive 集成,你可以与数以百万计的消费者、学生和商业用户建立联系,并与每天都在其中工作的客户进行互动。With over 500 million devices running the OneDrive app and over 85% of the Fortune 500 using OneDrive for Business, by integrating your app with OneDrive, you can connect with millions of consumers, students, and business users and engage with customers where they already do their work every day.

将应用文件存储在功能强大的云中Store your app's files in a powerful cloud

当你将文件存储在 OneDrive 中时,应用可以利用 Microsoft 云的功能,且你的用户可以在任何地方访问他们的文件。When you store your files in OneDrive, your app can take advantage of the features of the Microsoft cloud and your users can access their files anywhere. 通过[文件选择器][] SDK,可以使用 OneDrive 用户熟悉的相同体验,快速打开、下载、保存或共享存储在 OneDrive 中的文件。Use the file picker SDK to quickly open, download, save, or share files stored in OneDrive from within your own app, using the same experience OneDrive users are familiar with. 从选取器 SDK 中直接获取关于选定文件的信息,或者直接使用 Microsoft Graph API 与文件进行更深入的交互。Get information about selected files directly from the picker SDK, or use Microsoft Graph APIs directly to interact more deeply with files. 使用[][]“特殊文件夹”将文件存储在 OneDrive 上的已知位置,如 DocumentsCamera Roll,或者为你的应用提供其自己的个人文件夹。Use special folders to store files in well-known locations on OneDrive, like Documents and Camera Roll, or give your app its own personal folder.

在 OneDrive 中直接向用户提供你的应用Bring your app straight to users within OneDrive

OneDrive 客户可以直接在 OneDrive 中使用或启动你的应用,以打开、编辑或预览文件。OneDrive customers can use or launch your app directly from within OneDrive to open, edit, or preview files. 使用 OneDrive 的文件处理程序扩展,为你自己的自定义文件扩展名提供图标和预览,将你的应用添加到“新建”**** 按钮,甚至可以将你自己的自定义操作添加到菜单栏以启动应用。Use OneDrive's file handler extensions to provide icons and previews for your own custom file extensions, add your app to the New button or even add your own custom actions to the menu bar to launch your app.

使用应用理解的格式来处理内容Work with content in formats your app understands

应用可以以最方便的格式获取文件内容。Your app can get file content in the format that is most convenient for you. 应用可以显示数百种不同文件格式的自定义大小的“缩略图”[][]。Your app can display custom-sized thumbnails for hundreds of different file formats. 你可以下载各种不同“格式”[][]的文件,如 PDF。You can download files in a variety of alternative formats, like PDF. 甚至可以在应用中使用[][]预览 API (beta) 嵌入的 OneDrive 文件预览程序。You can even embed the OneDrive file previewers within your app by using the preview API (beta).

在不下载二进制文件的情况下使用文件内容和元数据Work with file content and metadata without downloading the binary

使用 Microsoft Graph,可以通过 REST API 访问丰富的内容,而无需下载二进制文件。With Microsoft Graph, you can access rich content through REST APIs without having to download the binary. 在[][]“照片”、[][]“音频”和[][]“视频”文件中探索提取的元数据。Explore extracted metadata from photo, audio, and video files. 使用 Excel API[][] 可直接使用存储在 Excel 工作簿中的原始数据。Use the Excel API to work directly with the raw data stored in an Excel workbook. 使用[][]注释 API 可访问 OneNote 笔记本内容。Use the Notes API to access the contents of OneNote notebooks.

对文件更改做出反应React to file changes

通过 webhooks[][],当文件发生更改时你将收到通知,以此可以快速做出响应。With webhooks, your app can get notified when files change so you can quickly react. delta API 可用于查看自上次应用与云同步以来发生的更改。Use the delta API to see what changed since the last time your app synchronized with the cloud.

API 参考API reference

在查找此服务的 API 参考?Looking for the API reference for this service?

后续步骤Next steps

详细了解如何在 Microsoft Graph v1.0 中使用 OneDrive APIFind out more about using the OneDrive API in Microsoft Graph v1.0.