TransWikia.com

how can use Yandex Disk c# Api

Stack Overflow Asked by EmreARAS on December 9, 2021

We want to use yandex disk api. Users can upload and delete files using the yandex disk.

I think getting a token from a login page. I tried a lot of sdk but I couldn’t find the sample code working properly.

Could you help?
i use https://github.com/yandex-disk/yandex-disk-sdk-csharp sdk

but sdk is WPF i use winform

this.sdkClient.AuthorizeAsync(new WebBrowserBrowser(browser), CLIENT_ID, RETURN_URL, this.CompleteCallback);
…
private void CompleteCallback(object sender, GenericSdkEventArgs<string> e)
{
    if (this.AuthCompleted != null)
    {
        this.AuthCompleted(this, new GenericSdkEventArgs<string>(e.Result));
    }

    this.Close();
}

public event EventHandler<GenericSdkEventArgs<string>> AuthCompleted;

One Answer

Implementing the solution to your problem at the bottom of the page on GitHub: https://github.com/raidenyn/yandexdisk.client

// PM> Install-Package YandexDisk.Client

using YandexDisk.Client.Http;
using YandexDisk.Client.Clients;

namespace Yandex_Disk
{
    class Yandex_Disk_Functions
    {
        private const string Token = "AgADAASAUssBGGAADSFfcRFRBurE1Rstu0WtsR7-d2";

        internal static async void UpLoad(string DiskPath, string LocalPath) =>
                await new DiskHttpApi(Token).Files.UploadFileAsync(DiskPath, false, LocalPath, CancellationToken.None);

        internal static async void DownLoad(string DiskPath, string LocalPath) => 
                await new DiskHttpApi(Token).Files.DownloadFileAsync(DiskPath, LocalPath);
    }
}

Answered by notSchizo on December 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP