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
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
