OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
294 stars 143 forks source link

How do you use OneDriveClient with UWP BackgroundUploader #187

Closed mscherotter closed 2 weeks ago

mscherotter commented 7 years ago

What is the recommended way of using the OneDriveClient with the UWP BackgroundUploader class? Michael

RussWalton commented 7 years ago

I would like to know how to do this too.

Thanks Russ

mscherotter commented 7 years ago

I figured it out:

private static async Task<UploadOperation> BackgroundUploadAsync(
    OneDriveClient oneDriveClient, 
    string oneDriveToken, 
    StorageFile file)
{
    var uploader = new BackgroundUploader();

    uploader.SetRequestHeader("Authorization", "bearer " + oneDriveToken);
    uploader.SetRequestHeader("Content-Type", "application/octet-stream");
    uploader.Method = "PUT";

    var request = oneDriveClient.Drive.Special.AppRoot.ItemWithPath(file.Name).Content.Request();

    var uri = new Uri(request.RequestUrl);

    var operation = uploader.CreateUpload(uri, file);

    return await operation.StartAsync();
}
cdmayer commented 7 years ago

Thank you for submitting. I like the way you got this done! However, I think this could be integrated better into the SDK. Perhaps I can some client extensions that are UWP-specific. I will add the Enhancement tag and keep this in mind for the future. Thanks!

baywet commented 2 weeks ago

Thank you for reaching out and for your patience. This SDK is being officially deprecated. See #259 for more information