【问题标题】:Create App folder and upload file using OneDrive API使用 OneDrive API 创建 App 文件夹并上传文件
【发布时间】:2015-10-28 18:01:22
【问题描述】:

我已将我的应用与 OneDrive SDK/API 连接到我的 OneDrive。 但是我怎样才能创建一个 AppFolder 并上传一个文本文件呢?

我设置了一个范围:

private readonly string[] scopes = new string[] { "onedrive.readwrite", "wl.offline_access", "wl.signin" };

并对用户进行身份验证:

((App)Application.Current).OneDriveClient = OneDriveClientExtensions.GetUniversalClient(this.scopes);
await ((App)Application.Current).OneDriveClient.AuthenticateAsync();

并将客户端存储在变量中:

var myOneDriveClient = ((App)Application.Current).OneDriveClient;

有人可以帮我完成接下来的步骤吗?

【问题讨论】:

    标签: c# onedrive


    【解决方案1】:

    获取应用文件夹的方法如下:

    var folder = await myOneDriveClient.Drive.Special.AppRoot.Request().GetAsync();
    

    上传工作如下:

    var item = await myOneDriveClient
        .Drive
        .Special
        .AppRoot
        .Children["filename"]
        .Content
        .Request()
        .PutAsync<Item>(contentStream);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      相关资源
      最近更新 更多