Microsoft Graph - OneDrive API - Convert to jpg before download(Microsoft Graph-OneDrive API-下载前转换为jpg)
问题描述
我正在尝试访问两个OneDrive项目。第一个是.docx
,第二个是.tif
。我想在下载它们之前将它们转换为.jpg
。
当我运行内容请求时...
// gets access to the service
GraphServiceClient graphServiceClient = await GetGraphServiceClient();
// get the item
DriveItem item = await graphServiceClient
.Drive
.Root
.ItemWithPath("xxx")
.Request()
.GetAsync();
// set up query params
List<Option> options = new List<Option>();
options.Add(new QueryOption("format", "jpg"));
// get content stream for item, converted to .jpg format
item.Content = await graphServiceClient
.Drive
.Root
.ItemWithPath("xxx")
.Content.Request(options)
.GetAsync();
这将引发Unknown Error
服务异常。
我认为它可能是一个格式不正确请求,但我可以将QueryOption格式更改为pdf
,它会如您预期的那样返回。
Here is the documentation for converting prior to download, showing that these formats are both supported to convert to jpg.
有人知道这里可能出了什么问题吗?为什么我无法检索jpg,但可以检索pdf?
推荐答案
Microsoft Graph v1.0仅支持converting to pdf
。仅the Beta endpoint支持转换为其他格式的功能。
/v1.0
支持:
format=pdf
/beta
支持:
format=pdf
format=html
format=glb
format=jpg
遗憾的是,OneDrive documentation没有区分生产和测试版功能。出于这个原因,我不建议将其作为主要来源。就像这样很容易被绊倒。
为了转换为jpg
,您需要使用Beta终结点,但将BaseUrl
属性设置为"https://graph.microsoft.com/beta"
。只需确保仅针对此方案执行此操作,而不是全局执行。Beta端点不够稳定,不能用于生产,因此它应该仅用于开发/测试和"没有其他方法"的场景。
这篇关于Microsoft Graph-OneDrive API-下载前转换为jpg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Microsoft Graph-OneDrive API-下载前转换为jpg


- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01