protected void Button1_Click(object sender, EventArgs e) { //string filePath = FastDFSClient.Upload("test", FileUpload1.FileBytes,"jpg"); string filePath = FastDFSClient.Upload(FileUpload1.FileBytes, "jpg"); Response.Write(filePath); }
protected void Button1_Click(object sender, EventArgs e) { try { string guid = Guid.NewGuid().ToString(); if (null != _logger) { _logger.InfoFormat("上传文件的大小为:{0}字节!", FileUpload1.PostedFile.ContentLength); } DateTime begin = DateTime.Now; string filePath = FastDFSClient.Upload("g1", FileUpload1.FileBytes, Tooklit.GetExtension(FileUpload1.FileName)); TimeSpan span = DateTime.Now - begin; if (null != _logger) { _logger.InfoFormat("上传文件Id为:{0}!路径为{1}!", guid, filePath); } if (null != _logger) { _logger.InfoFormat("上传文件的时间为:{0}秒!", span.TotalSeconds); } Response.Write("上传成功!"); } catch (Exception exc) { Response.Write("上传失败!"); if (null != _logger) { _logger.ErrorFormat("测试文件上传速度时发生异常:{0}" + exc.Message); } } }