public async Task <bool> MultarAsync(CriarMultaNova criarMultaNova, HttpUpload.FileInfo fileInfo) { var httpUpload = new HttpUpload(ObterUrl(urlMaisNovos)); var response = await httpUpload.Upload(fileInfo, criarMultaNova.ObterValores()); return(response.StatusCode == HttpStatusCode.Created); }
/// <summary> /// 创建上载任务 /// </summary> /// <param name="FileName">保存文件名</param> /// <param name="FilePath">上载文件路径</param> /// <param name="UploadPath">保存目录</param> /// <returns></returns> public HttpUpload CreateUploadTask(string FileName, string FilePath, string UploadPath) { int id = Tasks.Count; HttpTask task = new HttpUpload { ID = id, FileName = FileName, FilePath = FilePath, UploadPath = UploadPath }; Tasks.Add(id, task); return((HttpUpload)task); }
public HttpUpload ToHttpUpload() { var upload = new HttpUpload() { Name = Name, Filename = Filename, }; if (Text != null) { upload.Stream = new MemoryStream(Encoding.UTF8.GetBytes(Text)); } else { upload.Stream = File.OpenRead(Filename); } return(upload); }
/// <summary> /// Start image uploading process to FTP server. /// </summary> private void httpUploadButton_Click(object sender, RoutedEventArgs e) { MainWindow mainWindow = Owner as MainWindow; httpUploadButton.IsEnabled = false; httpUploadCancelButton.IsEnabled = true; httpUploadProgressBar.Value = 0; System.Net.ServicePointManager.Expect100Continue = false; try { _httpUpload = new HttpUpload(this); _httpUpload.StatusChanged += new EventHandler <Vintasoft.WpfTwain.ImageUploading.Http.StatusChangedEventArgs>(_httpUpload_StatusChanged); _httpUpload.ProgressChanged += new EventHandler <Vintasoft.WpfTwain.ImageUploading.Http.ProgressChangedEventArgs>(_httpUpload_ProgressChanged); _httpUpload.Completed += new EventHandler <Vintasoft.WpfTwain.ImageUploading.Http.CompletedEventArgs>(_httpUpload_Completed); _httpUpload.Url = httpUrlTextBox.Text; _httpUpload.Timeout = 5000; _httpUpload.UseDefaultCredentials = true; _httpUpload.AddTextField(httpTextField1TextBox.Text, httpTextField1ValueTextBox.Text); _httpUpload.AddTextField(httpTextField2TextBox.Text, httpTextField2ValueTextBox.Text); _httpUpload.AddFileField(httpFileFieldTextBox.Text, httpFileFieldValueTextBox.Text, _acquiredImageToUpload.GetAsStream(GetImageFileFormat(httpFileFieldValueTextBox.Text))); _httpUpload.PostData(); } catch (Exception ex) { MessageBox.Show(ex.Message, "HTTP error", MessageBoxButton.OK, MessageBoxImage.Error); httpUploadButton.IsEnabled = true; httpUploadCancelButton.IsEnabled = false; } finally { httpUploadProgressBar.Maximum = _httpUpload.BytesTotal; } }
public void Upload(string[] paths, string savePath) { string url = "http://tool.oschina.net/action/jscompress/multi_js_compress"; var httpUpload = new HttpUpload(); httpUpload.SetFieldValue("linebreak", "500000"); httpUpload.SetFieldValue("munge", Setting.Options.minJsMunge.ToString()); for (int i = 0; i < paths.Length; i++) { string path = paths[i]; string fieldName = "file"; if (i > 0) { fieldName += (i + 1); } byte[] fileBytepdf = File.ReadAllBytes(path); httpUpload.SetFieldValue(fieldName, fieldName, "application/x-javascript", fileBytepdf); } string responStr = ""; bool result = httpUpload.Upload(url, out responStr); if (result) { PathHelper.CheckPath(savePath); File.WriteAllText(savePath, responStr); } else { Console.WriteLine("[Error]" + responStr); } Console.WriteLine((result ? "成功" : "失败") + " " + savePath); }
public async Task <IActionResult> Post() { var obj = new HttpUpload(); return(await obj.GetUploadedFiles()); }
public async Task<bool> MultarAsync(CriarMultaNova criarMultaNova, HttpUpload.FileInfo fileInfo) { var httpUpload = new HttpUpload(ObterUrl(urlMaisNovos)); var response = await httpUpload.Upload(fileInfo, criarMultaNova.ObterValores()); return response.StatusCode == HttpStatusCode.Created; }