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=pdfformat=htmlformat=glbformat=jpg
遗憾的是,OneDrive documentation没有区分生产和测试版功能。出于这个原因,我不建议将其作为主要来源。就像这样很容易被绊倒。
为了转换为jpg,您需要使用Beta终结点,但将BaseUrl属性设置为"https://graph.microsoft.com/beta"。只需确保仅针对此方案执行此操作,而不是全局执行。Beta端点不够稳定,不能用于生产,因此它应该仅用于开发/测试和"没有其他方法"的场景。
这篇关于Microsoft Graph-OneDrive API-下载前转换为jpg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Microsoft Graph-OneDrive API-下载前转换为jpg
基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
