public static bool UploadToMailRuCloud(CloudDrive value, string file, out string message) { bool result = false; try { System.Threading.Tasks.Task.Run(() => { var api = new MailRuCloudApi.MailRuCloud(value.Uid, value.Password); result = api.Account.Login(); if (result) { result = api.UploadFile(new FileInfo(file), "/").Result; Console.WriteLine(result); } }).GetAwaiter().GetResult(); //var api = new MailRuCloudApi.MailRuCloud(); //api.Account = new MailRuCloudApi.Account(value.Uid, value.Password); //var percent = 0; //api.ChangingProgressEvent += delegate (object sender, ProgressChangedEventArgs e) //{ // percent = e.ProgressPercentage; //}; //var task = api.UploadFile(new FileInfo(file), "/"); //if (task.Result) //{ // if (percent == 100) // { // message = string.Empty; // return true; // //Thread.Sleep(5000); // } // else // { // message = string.Empty; // return false; // } //} //else //{ message = string.Empty; return(result); } catch (Exception e) { message = e.Message; return(false); } }
private Stream OpenReadStream(MailRuCloudApi.MailRuCloud cloud, long?start, long?end) { Stream stream = cloud.GetFileDownloadStream(_fileInfo, start, end).Result; return(stream); }