如何向其他用户OneDrive文件夹上传文件?权限疑问求证
问题详情
环境信息
- 系统:Win11
- Graph API版本:5
- Graph API权限:Users.Read, Files.ReadWrite
问题描述
未抛出任何错误,我已开启Graph API调用日志,也未发现日志中有错误。
该调用在我这里完全正常,但我是该OneDrive子文件夹的所有者。
我甚至为该子文件夹更新了访问权限,确保至少有一位用户拥有编辑文件夹内项目的权限。
多年前的类似帖子推荐使用Files.ReadWrite.All权限。
能否有人对此进行确认?我没有权限为公司所有人甚至单个用户授予该权限,我希望能带着确定的结论而非猜测去咨询安全团队。
代码示例
private async static Task UploadFile(string filePath) { string oneDriveRootId = "-- drive id of root OneDrive folder --"; string itemId = "-- ID OF SUBFOLDER --"; try { byte[] data = System.IO.File.ReadAllBytes(filePath); using (Stream stream = new MemoryStream(data)) { var graphClient = GraphAuthentication.GetGraphServiceClient(loggedOnUserEmail); var item = await graphClient.Drives[oneDriveRootId] .Items[itemId] .ItemWithPath(filePath) .Content .PutAsync(stream); } } catch (Exception ex) { Console.WriteLine(" Error uploading {0}\n\n{1}", filePath, ex); } }
内容的提问来源于stack exchange,提问作者ezG
相关产品推荐
相关产品推荐

