private static async void StartUpload() { if (Form.Uploading) { return; } if (UploadQueue.Count == 0) { return; } UploadContract contract = UploadQueue.Dequeue(); try { contract.Uploader = await Client.UploadFile(contract.Path, contract.Filename); } catch (RetryException e) { if (e.LastException is IOException) { MessageBox.Show($"Couldn´t upload file \"{contract.Filename}\":\n{e.Message}"); StartUpload(); return; } throw; } Form.StartUpload(contract); }
public void StartUpload(UploadContract contract) { StatusLabel.Invoke(new Action(() => StatusLabel.Text = "Uploading: " + contract.Filename)); Uploading = true; FileUpload = contract; UploadTimer.Start(); }
public static void UploadFile(string filename) { if (!File.Exists(filename)) { throw new FileNotFoundException(); } UploadContract c = new UploadContract { Uploader = null, Path = filename, Filename = Path.GetFileName(filename), Share = true, FirstView = false, Public = true, PublicRegistered = true, Whitelisted = false, Whitelist = "" }; Enqueue(c); }
private async void UploadButton_Click(object sender, EventArgs e) { if (File.Exists(PathText.Text) && !Uploading) { FileUploader u = await Client.UploadFile(PathText.Text, FilenameText.Text); var c = new UploadContract { Uploader = u, Path = PathText.Text, Filename = FilenameText.Text, Share = ShareBox.Checked, FirstView = FirstViewBox.Checked, Public = PublicBox.Checked, PublicRegistered = PublicRegisteredBox.Checked, Whitelisted = WhitelistedBox.Checked, Whitelist = WhitelistText.Text }; StartUpload(c); } }
public static void Enqueue(UploadContract contract) { UploadQueue.Enqueue(contract); StartUpload(); }