public void CanUploadWithRegisteredProtocol() { _uploader.Upload("C:\\locala".ToAbsoluteFilePath(), TestUrl); A.CallTo(() => _strategy.Upload(GetUploadSpec("C:\\locala".ToAbsoluteFilePath(), TestUrl))) .MustHaveHappened(Repeated.Exactly.Once); }
public static void T() { FileUploader loader = new FileUploader(); loader.FileUploaded += Progress; loader.Upload(); }
public void UseStandardEventModel() { FileUploader fl = new FileUploader(); fl.FileUploaded += Progress; fl.Upload(); }
// 上传文件操作 protected virtual void UploadFile() { IsUploading = true; while ((m_files.Count(f => f.UploadStatus == UploadStatus.Uploading || f.UploadStatus == UploadStatus.Resizing) < MaxConcurrentUploads) && IsUploading) { if (m_files.Count(f => f.UploadStatus != UploadStatus.Complete && f.UploadStatus != UploadStatus.Uploading && f.UploadStatus != UploadStatus.Resizing) > 0) { FileUploader fu = m_files.First(f => f.UploadStatus != UploadStatus.Complete && f.UploadStatus != UploadStatus.Uploading && f.UploadStatus != UploadStatus.Resizing); fu.Upload(); } else if (m_files.Count(f => f.UploadStatus == UploadStatus.Uploading || f.UploadStatus == UploadStatus.Resizing) == 0) { IsUploading = false; uploadButton.Content = "上传"; this.UploadedFilesString = this.UploadedFilesString.TrimEnd(','); if (!string.IsNullOrEmpty(JsCompleteFunction)) { try { HtmlPage.Window.Invoke(JsCompleteFunction, this.UploadedFilesString); } catch (Exception e) { } } } else { break; } } }
public ActionResult Create(Panorama panorama, HttpPostedFileBase photo) { if (photo != null) { panorama.PictureUrl = photo.FileName; } panorama.UserId = User.Identity.GetUserId(); panorama.AddedOn = DateTime.Now; if (ModelState.IsValid && photo != null) { db.Panorama.Add(panorama); db.SaveChanges(); string extension = Path.GetExtension(photo.FileName); FileUploader.Upload(photo, panorama.Id + extension); int[] PanoramaIds = new int[] { panorama.Id }; ExecuteKrpanotools(PanoramaIds, "sphere", 360, 180); return(RedirectToAction("Index")); //return RedirectToAction("CreatePano", new { id = panorama.Id, userId = panorama.UserId }); } return(View(panorama)); }
public void Execute() { FileUploader fileUp = new FileUploader(); fileUp.FileUploaded += Progress; fileUp.Upload(); }
public async Task <ActionResult <ProductImageVM> > Post(List <IFormFile> files) { foreach (var file in files) { FileUploader.Upload(file, hostingEnvironment); } return(null); }
public void fileuploader_upload_assert() { var client = Client.DemoClient(); var file = new FileInfo("test.png"); var uploader = new FileUploader(client, file); var result = uploader.Upload(); Assert.NotNull(result.FileId); }
protected void btnUpdate_Click(object sender, EventArgs e) { string filename = ""; if (fuPics.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief" }; fu = new FileUploader(); filename = fu.Upload(fuPics, 1d, Session["LoginUser"].ToString() + "" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "UploadPics/" + HiddenContractorID.Value + "/", extension); } }
public void fileuploader_upload_bytes() { var client = Client.DemoClient(); var file = new FileInfo("test.png"); var bytes = File.ReadAllBytes(file.FullName); var uploader = new FileUploader(client, bytes, file.Name); var result = uploader.Upload(); Assert.NotNull(result.FileId); }
public void client_getfile_assert() { var client = Client.DemoClient(); var file = new FileInfo("test.png"); var uploader = new FileUploader(client, file); var uploadedFileInfo = uploader.Upload(); var result = client.GetFile(uploadedFileInfo.FileId); Assert.NotNull(result.FileId); }
/// <summary> /// 範例method /// </summary> public void method() { FileUploader f1 = new FileUploader(); f1.FileUploaded += Progress; //將檔案加入上傳 f1.FileUploaded += ProgressAnother; //將檔案加入上傳 //1. 因為有event保護:禁止清空 //f1.FileUploaded = null; //2. 因為有event保護:禁止改值 //f1.FileUploaded(10); f1.Upload(); }
public string Put() { MasterDbContext masterDbContext = new MasterDbContext(connString); DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>(); try { string reqType = this.ReadQueryStringData("reqType"); int empId = ToInt(this.ReadQueryStringData("empId")); var files = Request.Form.Files; string ImagePath = null; string ImageName = null; if (files.Count != 0) { // DanpheHTTPResponse <object> uploadResponse = FileUploader.Upload(files, "UserProfile\\"); if (uploadResponse.Status == "OK") { ImagePath = uploadResponse.Results.ToString(); ImageName = files[0].FileName; EmployeeModel dbemp = masterDbContext.Employees.Where(a => a.EmployeeId == empId) .FirstOrDefault <EmployeeModel>(); dbemp.ImageFullPath = ImagePath; dbemp.ImageName = ImageName; masterDbContext.Entry(dbemp).State = EntityState.Modified; responseData.Status = "OK"; masterDbContext.SaveChanges(); responseData.Results = ImageName; } else { throw new Exception("Upload Failed"); } } else { responseData.ErrorMessage = "Upload Failed"; responseData.Status = "Failed"; } } catch (Exception ex) { responseData.Status = "Failed"; responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString(); } return(DanpheJSONConvert.SerializeObject(responseData, true)); }
protected void btnApply_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Conn"].ToString())) { try { if (Session["ProfileID"] != null) { string filename = ""; if (FU_ApplyJob_AttachFile.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief", ".pdf", ".doc", ".xls", ".docx", ".xlsx", ".txt" }; fu = new FileUploader(); filename = fu.Upload(FU_ApplyJob_AttachFile, 1d, Session["LoginUser"].ToString() + "AttachForApplyJob" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "../Upload/Attachment/", extension); } DateTime ReqDatedt = DateTime.Parse(lblPostedDate.Text); string UserName = Session["ProfileID"].ToString(); dtinfo.ShortDatePattern = "dd/MM/yyyy"; dtinfo.DateSeparator = "/"; Connection.Open_Connection(con); cmd = new SqlCommand("spApplyJob", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ContractorID", SqlDbType.VarChar, 50).Value = Convert.ToInt32(UserName.ToString()); cmd.Parameters.Add("@JID", SqlDbType.Int).Value = Request.QueryString["JobID"].ToString(); cmd.Parameters.Add("@Message", SqlDbType.NVarChar, 255).Value = txtRepaly.InnerHtml; cmd.Parameters.Add("@RequestDate", SqlDbType.DateTime).Value = Convert.ToDateTime(ReqDatedt, dtinfo); cmd.Parameters.Add("@Attachment", SqlDbType.VarChar, 100).Value = filename; cmd.Parameters.Add("@Msg", SqlDbType.NVarChar, 500); cmd.Parameters["@Msg"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); Connection.Close_Connection(con); if (cmd.Parameters["@Msg"].Value.ToString().Trim() == "OK") { con.Dispose(); cmd.Dispose(); Dispose(); Response.Write("<script>alert('Contract Successfully Submitted.'); </script>"); Response.Redirect("~/ProfileContractor/FindJob.aspx", false); } { } cmd.Dispose(); } } catch (Exception ex) { ccl.ShowError(ex); } } }
public void TestUploadBinary() { TransferStatus status = FileUploader.Upload(LocalPathUpload2, RemotePathUpload2, _adlsClient, 10, IfExists.Overwrite, null, false, false, true, default(CancellationToken), false, TransferChunkSize); Assert.IsTrue(status.EntriesFailed.Count == 0); Assert.IsTrue(status.EntriesSkipped.Count == 0); long origSuccess = status.FilesTransfered; Queue <DirectoryInfo> localQueue = new Queue <DirectoryInfo>(); Queue <DirectoryEntry> remoteQueue = new Queue <DirectoryEntry>(); localQueue.Enqueue(new DirectoryInfo(LocalPathUpload2)); remoteQueue.Enqueue(_adlsClient.GetDirectoryEntry(RemotePathUpload2)); Verify(localQueue, remoteQueue); status = FileUploader.Upload(LocalPathUpload2, RemotePathUpload2, _adlsClient, 10, IfExists.Fail, null, false, false, true, default(CancellationToken), false, TransferChunkSize); Assert.IsTrue(origSuccess == status.EntriesSkipped.Count); }
protected void btnSubmit_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CrewsdbConnectionString"].ConnectionString)) { ccl = new CommanClass(); try { string filename = ""; if (FU_PJ_Attachment.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief", ".pdf", ".doc", ".xls", ".docx", ".xlsx", ".txt" }; fu = new FileUploader(); filename = fu.Upload(FU_PJ_Attachment, 1d, Session["LoginUser"].ToString() + "Attach" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "../Upload/AttachmentJob/", extension); } if (!string.IsNullOrEmpty(Session["ProfileID"].ToString())) { string UserName = Session["ProfileID"].ToString(); dtinfo.ShortDatePattern = "dd/MM/yyyy"; dtinfo.DateSeparator = "/"; Connection.Open_Connection(con); cmd = new SqlCommand("spPostJob", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ProfileID", SqlDbType.Int).Value = Convert.ToInt32(UserName); cmd.Parameters.Add("@JobTitle", SqlDbType.VarChar, 20).Value = txtTitleofWork.Text.ToString(); cmd.Parameters.Add("@Description", SqlDbType.NVarChar).Value = txtDescription.Text.ToString(); cmd.Parameters.Add("@Hours", SqlDbType.Decimal).Value = Convert.ToInt32(txtHours.Text.ToString()); cmd.Parameters.Add("@Budget", SqlDbType.Money).Value = txtAmount.Text.ToString(); cmd.Parameters.Add("@ExpDate", SqlDbType.DateTime).Value = Convert.ToDateTime(txtDate.Text, dtinfo); cmd.Parameters.Add("@CategoryName", SqlDbType.VarChar, 20).Value = ddlCategory.SelectedItem.Text; cmd.Parameters.Add("@Attachment", SqlDbType.VarChar, 100).Value = filename; cmd.Parameters.Add("@Msg", SqlDbType.VarChar, 500); cmd.Parameters["@Msg"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); if (Convert.ToString(cmd.Parameters["@Msg"].Value) == "OK") { txtTitleofWork.Text = txtHours.Text = txtDescription.Text = txtAmount.Text = txtDate.Text = ""; lblError.Text = "Your Job successfully posted."; } } } catch (Exception ex) { ccl.ShowError(ex); } } }
protected void btnSend_Click(object sender, EventArgs e) { try { string filename = ""; if (fuPhoto.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief", ".pdf", ".doc", ".xml", ".docx", ".txt" }; FileUploader fu = new FileUploader(); filename = fu.Upload(fuPhoto, 1d, Session["LoginUser"].ToString() + "" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "../Upload/AttachmentChat/", extension); } lblMessage.Text = chat.PostMessage(Convert.ToInt32(ddlJobTitle.SelectedValue), Convert.ToInt32(Session["ProfileID"]), txtMessage.Text, filename); } catch (Exception ex) { lblMessage.Text = "Please Provide valide information."; } }
protected void UploadBtn_Click(object sender, EventArgs e) { // Check if there is no date if (uploaddatepicker.Value == "") { return; } // Check if there is no time if (uploadtimepicker.Value == "") { return; } // Check if there is no file name if (uploadName.Text == "") { return; } // Check if there is no file if (!FileUp.HasFile) { return; } // uploaddatepicker Example : 2016-04-01 string[] date_ = uploaddatepicker.Value.Split('-'); string date = date_[0] + date_[1] + date_[2]; // uploadtimepicker Example : 14 : 06 string time = uploadtimepicker.Value.ElementAt(0).ToString() + uploadtimepicker.Value.ElementAt(1).ToString() + uploadtimepicker.Value.ElementAt(3).ToString() + uploadtimepicker.Value.ElementAt(4).ToString(); string datasetName = date + time; if (FileUp.HasFile) { FileUploader.Upload(FileUp.FileContent, FileUp.FileName, datasetName, uploadName.Text); } }
public void SwitchRecording() { if (isRecording) { Debug.Log("Tried to save"); //Save(Application.persistentDataPath + "/filename.wav"); audioRenderer.recOutput = false; isRecording = false; audioRenderer.WriteHeader(); FileStream file = File.OpenRead(Application.persistentDataPath + "recTesterzzz.wav"); Debug.Log("Click :3"); fileUploader.Upload(Application.persistentDataPath + "recTesterzzz.wav", file); } else { Debug.Log("Start recording"); audioRenderer.recOutput = true; isRecording = true; } }
public async Task<JsonResult> Upload() { try { foreach (string file in Request.Files) { var fileContent = Request.Files[file]; if (fileContent != null && fileContent.ContentLength > 0) { var uploader = new FileUploader(fileContent, "files"); var uploadedFile = await uploader.Upload(); } } } catch (Exception) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json("Upload failed"); } return Json("File uploaded successfully"); }
private void PostMessage(int jobid, int profileid) { using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Conn"].ToString())) { string filename = ""; if (fuPhoto.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief", ".pdf", ".doc", ".xml", ".docx", ".txt" }; FileUploader fu = new FileUploader(); filename = fu.Upload(fuPhoto, 1d, Session["LoginUser"].ToString() + "" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "../Upload/AttachmentChat/", extension); } string usertype = ccl.UserType(); cmd = new SqlCommand("spChat", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Mode", "Post"); cmd.Parameters.AddWithValue("@JobID", jobid); cmd.Parameters.AddWithValue("@UserType", usertype); cmd.Parameters.AddWithValue("@SendFrom", profileid); cmd.Parameters.AddWithValue("@SendTo", profileid); cmd.Parameters.AddWithValue("@Message", txtMessage.Text); cmd.Parameters.AddWithValue("@PhotoURL", filename); cmd.Parameters.Add("@Msg", SqlDbType.NVarChar, 500); cmd.Parameters["@Msg"].Direction = ParameterDirection.Output; Connection.Open_Connection(con); cmd.ExecuteNonQuery(); Connection.Close_Connection(con); string msg = Convert.ToString(cmd.Parameters["@Msg"].Value); if (msg == "OK") { lblMessage.Text = "Message Posted."; } else { lblMessage.Text = "Please Profide valide information."; } cmd.Dispose(); } }
protected void BtnSend_Click(object sender, EventArgs e) { if (Session["UserType"] != null) { string filename = ""; if (FUAttachment.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief", ".pdf", ".doc", ".xls", ".docx", ".xlsx", ".txt" }; fu = new FileUploader(); filename = fu.Upload(FUAttachment, 1d, Session["LoginUser"].ToString() + "AttachForApplyJob" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "~/Upload/Attachment/", extension); } Connection.Open_Connection(con); cmd = new SqlCommand("spInsertConversation", con); cmd.CommandType = CommandType.StoredProcedure; if (Usertype == "Hirer") { cmd.Parameters.Add("@ContractorUserName", SqlDbType.VarChar, 50).Value = lblContractorUserName.Text; cmd.Parameters.Add("@HirerUserName", SqlDbType.VarChar, 50).Value = Loginuser; } else if (Usertype == "Contractor") { cmd.Parameters.Add("@ContractorUserName", SqlDbType.VarChar, 50).Value = Loginuser; cmd.Parameters.Add("@HirerUserName", SqlDbType.VarChar, 50).Value = lblContractorUserName.Text; } //cmd.Parameters.Add("@ContractorUserName", SqlDbType.VarChar, 50).Value = lblContractorUserName.Text; //cmd.Parameters.Add("@HirerUserName", SqlDbType.VarChar, 50).Value = Session["LoginUser"].ToString(); cmd.Parameters.Add("@Message", SqlDbType.VarChar, 255).Value = txtReplayMsg.Value; cmd.Parameters.Add("@SendBy", SqlDbType.VarChar, 50).Value = Loginuser; cmd.Parameters.Add("@Attachment", SqlDbType.VarChar, 100).Value = filename; cmd.Parameters.Add("@UserType", SqlDbType.VarChar, 50).Value = Usertype; cmd.ExecuteNonQuery(); BindConversation(); } }
protected void btnSaveLogo_Click(object sender, EventArgs e) { try { using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Conn"])) { string filename = ""; if (fuPhoto.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief" }; fu = new FileUploader(); filename = fu.Upload(fuPhoto, 1d, Session["LoginUser"].ToString() + "Logo" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "Upload/Logo/", extension); Connection.Open_Connection(con); if (Session["UserType"] == "Contractor") { cmd = new SqlCommand("Update ProfileContractor set PhotoURL='" + filename + "' where ContractorID='" + Convert.ToInt32(HiddenContractorID.Value) + "'", con); } else { cmd = new SqlCommand("Update ProfileHirer set PhotoURL='" + filename + "' where HirerID='" + Convert.ToInt32(HiddenContractorID.Value) + "'", con); } cmd.ExecuteNonQuery(); cmd = new SqlCommand("Update Login set Step='4' where UserName='******'", con); cmd.ExecuteNonQuery(); imgLogo.Src = filename; Connection.Close_Connection(con); cmd.Dispose(); } } } catch (NullReferenceException ex) { Response.Redirect("Default.aspx"); } }
public void UploadFiles(RemoteFileInfo request) { FileUploader.Upload(request); }
protected void lbtnSubmit_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Conn"].ToString())) { string red = "N"; try { string filename = ""; if (fuPhoto.PostedFile.ContentLength != 0) { string[] extension = { ".jpg", ".gif", ".png", ".jpeg", ".gief" }; fu = new FileUploader(); filename = fu.Upload(fuPhoto, 1d, Session["LoginUser"].ToString() + "Logo" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Minute.ToString(), "Upload/Logo/", extension); } else { filename = "Upload/Logo/userbg.png"; } cmd = new SqlCommand("spProfileContractor", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Website", txtWebSite.Text); cmd.Parameters.AddWithValue("@ContractorNo", txtContractor.Text); cmd.Parameters.Add("@JobTitle", SqlDbType.VarChar, 100).Value = txtJobTitle.Text; cmd.Parameters.Add("@JobDescription", SqlDbType.NVarChar, 500).Value = txtPortfolioWorkDescription.Text; cmd.Parameters.Add("@Logo", SqlDbType.VarChar, 50).Value = filename; cmd.Parameters.Add("@Rate", SqlDbType.Money).Value = txtRate.Text; cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 30).Value = Session["LoginUser"].ToString(); cmd.Parameters.Add("@Address", SqlDbType.NVarChar, 50).Value = txtAddress.Text; cmd.Parameters.Add("@City", SqlDbType.NVarChar, 50).Value = ddlCity.SelectedValue.ToString(); cmd.Parameters.Add("@Location", SqlDbType.VarChar, 20).Value = txtLocation.Text; cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 20).Value = txtContactno.Text; cmd.Parameters.Add("@CountryID", SqlDbType.VarChar, 5).Value = ddlCountry.SelectedValue.ToString(); cmd.Parameters.Add("@Msg", SqlDbType.NVarChar, 255); cmd.Parameters["@Msg"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); string msg = cmd.Parameters["@Msg"].Value.ToString(); lblSinginError.Text = msg.ToString(); Connection.Close_Connection(con); cmd.Dispose(); if (msg != "OK") { lblWorkError.Text = lblSinginError.Text; lblWorkError.Focus(); } else { lblWorkError.ForeColor = System.Drawing.Color.Green; lblWorkError.Text = "Successfully Submitted."; red = "Y"; } } catch (Exception ex) { ccl = new CommanClass(); ccl.ShowError(ex); } finally { } if (red == "Y") { Response.Redirect("UpdatePics.aspx", true); } } }