/// <inheritdoc cref="IFileUploader"/> /// <summary> /// Uploads the file to mega.nz. /// </summary> /// <returns>The result as <see cref="string"/>.</returns> /// <seealso cref="IFileUploader"/> public async Task <string> UploadToMega() { var client = new MegaApiClient(); var possibleAccounts = this.GetPossibleAccounts("mega"); foreach (var account in possibleAccounts) { LoginMega(client, account); var info = await client.GetAccountInformationAsync(); if (info.UsedQuota + GetFileSize(this.FileName) > info.TotalQuota) { continue; } var root = GetRootFolderMega(client); var progress = this.GetProgress(); var node = await client.UploadFileAsync(this.FileName, root, progress, null); var link = await client.GetDownloadLinkAsync(node); await client.LogoutAsync(); return(link.AbsoluteUri); } return(string.Empty); }
/// <summary> /// /// </summary> /// <param name="cesta"></param> /// <param name="struktura"></param> public async static Task VytvorSoubory(string cesta, Mega_status MS, int i) { cesta = cesta.Replace('/', '\\'); string slozka = cesta.Remove(cesta.LastIndexOf("\\")); slozka = slozka.Substring(slozka.LastIndexOf("\\") + 1); if (slozka == "fotky") { slozka = "Fotky"; } var nodes = client.GetNodes(); INode slozka_cpy = nodes.FirstOrDefault(n => n.Name == slozka); // client.UploadFile(cesta, slozka_cpy); Progress <double> progress = new Progress <double>(); progress.ProgressChanged += (s, progressValue) => { //Update the UI (or whatever) with the progressValue MS.dataGridView2.Rows[i].Cells[1].Value = (int)progressValue; }; INode myFile = await client.UploadFileAsync(cesta, slozka_cpy, progress, uploadCancellationTokenSource.Token); }
private void Upload() { string yi = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))); string pa = @"\FFMPEG\doc\"; string n = "Saves.txt"; string c = yi + pa + n; if (File.Exists(c)) { string[] lines = File.ReadAllLines(c); client.Login(lines[0], lines[1]); Progress <double> ze = new Progress <double>(p => { Console.WriteLine($"Progress updated: {p}"); double d = Math.Round(p * 10000) / 10000d; lblVideoInfo.Content = d + "%" + " (Upload)"; prbPro.Value = d; }); IEnumerable <INode> nodes = client.GetNodes(); INode root = nodes.Single(x => x.Type == NodeType.Root); INode myFolder = client.CreateFolder("Upload-s" + a, root); td = Task.Run(() => { return(client.UploadFileAsync(V, myFolder, ze)); }); Upt.Interval = TimeSpan.FromMilliseconds(30); Upt.Tick += Upt_Tick; Upt.Start(); } }