简体   繁体   English

使用OneDrive API创建App文件夹和上传文件

[英]Create App folder and upload file using OneDrive API

i accomplished to connect my App with the OneDrive SDK/API to my OneDrive. 我完成了将我的应用程序与OneDrive SDK / API连接到我的OneDrive。 But how can i create an AppFolder and Upload ie a Textfile? 但是我如何创建AppFolder和上传即文本文件?

I set up a scope: 我设置了一个范围:

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

and authenticate the user: 并验证用户:

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

and store the Client in a variable: 并将客户端存储在变量中:

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

Can someone help me with the next steps? 有人可以帮助我完成下一步吗?

Here's how you can get the app folder: 以下是获取app文件夹的方法:

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

Upload would work like this: 上传将像这样工作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM