public IActionResult GetAppendMark(string bucket, string name, string query) { string visitUrl = $"/{bucket}/{name}"; var item = _bucketImageService.GetByVisitUrl(visitUrl); if (item == null) { return(NotFile()); } string abPath = Path.Combine(_hostingEnvironment.ContentRootPath, item.IOPath); if (!System.IO.File.Exists(abPath)) { return(NotFile()); } string cut = null, resize = null; Stream stream = null; if (!String.IsNullOrEmpty(query)) { var arr = query.Split(','); foreach (var q in arr) { string temp = q.ToLower(); if (temp.StartsWith("m_")) { cut = temp; } if (temp.StartsWith("w_") || temp.StartsWith("h_")) { resize = temp; } if (temp.Equals("l_logo")) { stream = _markLogoService.GetStream(); } } } using (var img = SkiaHelper.MakeThumb(abPath, cut, resize, item.ExtName, stream)) { return(File(img.ToArray(), $"image/{item.ExtName?.Substring(1)}")); } }
public IActionResult Get(string bucket, string mod, string crc32, string name, string query) { string abPath = System.IO.Path.Combine(MediaItemConfig.RootDir, bucket.ToLower(), mod, crc32, name.ToLower()); if (!System.IO.File.Exists(abPath)) { return(NotFile()); } string ext = Path.GetExtension(name) ?? ".jpg"; string cut = null, resize = null; Stream stream = null; if (!String.IsNullOrEmpty(query)) { query = query.ToLower(); if (!_bucketCutService.ValueExists(bucket, query.Replace(",l_logo", ""))) { return(NotFile()); } string thum_AbPath = System.IO.Path.Combine(MediaItemConfig.RootDir, bucket.ToLower(), mod, crc32, name.ToLower() + "!" + query.ToLower()); if (!System.IO.File.Exists(thum_AbPath)) { var arr = query.Split(','); foreach (var q in arr) { string temp = q.ToLower(); if (temp.StartsWith("m_")) { cut = temp; } if (temp.StartsWith("w_") || temp.StartsWith("h_")) { resize = temp; } if (temp.Equals("l_logo")) { stream = _markLogoService.GetStream(); } } using (var img = SkiaHelper.MakeThumb(abPath, cut, resize, ext, stream)) { var bt = img.ToArray(); using (FileStream fs = System.IO.File.OpenWrite(thum_AbPath)) { fs.Write(bt, 0, bt.Length); } return(File(bt, $"image/{ext.Substring(1)}")); } } else { abPath = thum_AbPath; } } using (FileStream fs = new FileStream(abPath, FileMode.Open)) { byte[] bt = new byte[fs.Length]; fs.Read(bt, 0, bt.Length); return(File(bt, $"image/{ext.Substring(1)}")); } }