Microsoft Graph获取文件名 [英] Microsoft Graph get filename
问题描述
当前只能从SharePoint在线(也称为Office 365)获取资源的文件名.身份验证和刷新令牌来自Unified Api示例(即Microsoft Graph).
Currently stuck with getting the filename of a ressource from SharePoint online aka Office 365. Authentication and refresh token is from the Unified Api example aka Microsoft Graph.
var authResult = await authContext.AcquireTokenByAuthorizationCodeAsync(
...
var imgBytes = await httpClient.GetByteArrayAsync(parameters.FileGet);
return File(imgBytes, "application/specialFormat", "File1.specialFormat");
此刻,我必须定义自己的文件名.我已经在 http://graph.microsoft.io/en上看到了该示例-us/docs/overview/overview ,但获取我的文件"示例仅显示如何获取一个人的文件,而不显示如何基于文件ID获取文件名.我希望有人可以澄清这一点.
At the moment I have to define my own filename. I' ve already seen the example at http://graph.microsoft.io/en-us/docs/overview/overview, but the "GET my files" example shows only how to get the files of one person and not how to get a filename based upon a file Id. I hope someone could clarify this.
https://graph.microsoft.com/v1.0/me/drive/root/children
使用Graph api获得基于文件ID的文件名还是必须使用其他内容?
Is getting a filename based upon the file id with the Graph api possible or do I have to use something else?
编辑 一些可行的查询:
EDIT Some queries that would work:
https://graph.microsoft.com/v1.0/me/drive/root/children?$select=id
https://graph.microsoft.com/v1.0/me/drive/root/children?$filter=name eq 'testfile.office'
但是,如果我尝试搜索特定的ID,查询将失败,并且我将不会获得任何信息.
But if I try to search for the specific id the query fails and I get none information.
https://graph.microsoft.com/v1.0/me/drive/root/children?$filter=id eq '01QXOQU7OCV7FW2BQNAZD3KNZMYXVMNJD6'
推荐答案
如果您具有商品ID,则可以按以下方式访问商品:
https://graph.microsoft.com/v1.0/me/drive/items/ID
If you have the item ID, you can access the item like this:
https://graph.microsoft.com/v1.0/me/drive/items/ID
如果您有路径,则可以按以下方式访问该项目:
https://graph.microsoft.com/v1.0/me/drive/root:/FOLDER/FOLDER/FOLDER/FILENAME.EXT
If you have the path, you can access the item like this:
https://graph.microsoft.com/v1.0/me/drive/root:/FOLDER/FOLDER/FOLDER/FILENAME.EXT
您可以通过路径进一步获得项的子项:
https://graph.microsoft.com/v1.0/me/drive/root:/FOLDER/FOLDER/FOLDER/FILENAME.EXT:/children
You can further get the children of an item by path:
https://graph.microsoft.com/v1.0/me/drive/root:/FOLDER/FOLDER/FOLDER/FILENAME.EXT:/children
通过MS Graph公开的Drive API与OneDrive公开的API几乎相同(如果不完全相同).请参阅此参考页: https://dev.onedrive.com/resources/item.htm
The Drive API exposed through MS Graph is pretty much (if not exactly) the same as the API exposed by OneDrive. See this reference page: https://dev.onedrive.com/resources/item.htm
这篇关于Microsoft Graph获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!