Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }