You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何向其他用户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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 13:34:57