public ActionResult Thumb(string size, ThumbnailMethod mode, int q, string fn, WaterMarkingPosition?position) { Response.Cache.SetOmitVaryStar(true); var filePath = StringUtility.XBase64Decode(fn); var arrSize = size.ToLower().Split('x'); var dirRoot = AttachmentSvc.GetFullPath($@"thumb\{mode}-{size}-{position}"); var filePathAbs = Path.Combine(dirRoot, filePath); var dirPath = Path.GetDirectoryName(filePathAbs); if (string.IsNullOrEmpty(dirPath)) { return(HttpNotFound("-File Not Found-")); } if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } var fileExt = Path.GetExtension(filePathAbs); if (!System.IO.File.Exists(filePathAbs)) { var iThumb = new ImgThumbUtillity() { QualityLevel = q }; var filePathSrc = AttachmentSvc.GetFullPath(filePath); iThumb.MakeThumbnail(filePathSrc, filePathAbs, fileExt, StringUtility.ConvertToInt(arrSize[0]), StringUtility.ConvertToInt(arrSize[1]), mode, position, SysConfigRepository.WaterMarkingPath); } var fileContentType = AttachmentSvc.GetFileContentType(fileExt); return(File(filePathAbs, fileContentType)); }
public ActionResult DownloadFile(long id) { var atta = AttachmentRepository.Get(id); if (atta == null) { return(HttpNotFound("不存在该附件")); } var attaPath = Path.Combine(SysConfigRepository.UploadPath, atta.FilePath); var fileContent = AttachmentSvc.GetFileContentType(atta.FileExt); return(File(attaPath, fileContent, atta.Name + atta.FileExt)); }
public ActionResult GetFile(string fn) { Response.Cache.SetOmitVaryStar(true); var filePath = StringUtility.XBase64Decode(fn); filePath = AttachmentSvc.GetFullPath(filePath); if (!System.IO.File.Exists(filePath)) { return(HttpNotFound("-File Not Found-")); } var fileExt = Path.GetExtension(filePath); var fileContentType = AttachmentSvc.GetFileContentType(fileExt); return(File(filePath, fileContentType)); }