public FileContentResult Resource([FromQuery] string id) { // return File((byte[])_helpResourceProvider.GetResource(id), "application/octet-stream", id); var ext = System.IO.Path.GetExtension(id); var contentType = "text/plain"; if (ext.ToLower().Contains("png")) { contentType = "image/png"; } return(new FileContentResult((byte[])_helpResourceProvider.GetResource(id), contentType)); }
public string InsertResources(string str) { if (_helpResourceProvider == null || string.IsNullOrWhiteSpace(str)) { return(str); } str = str.Replace(HelpConst.URL, ControllerURL, StringComparison.CurrentCulture); string pattern = HelpConst.EmbddedResPattern; MatchCollection col = Regex.Matches(str, pattern, RegexOptions.Singleline); foreach (Match m in col) { GroupCollection groups = m.Groups; var res = _helpResourceProvider.GetResource(groups[1].Value); if (res != null && groups[1].Value.ToLower().Contains(HelpConst.png)) { //it is image resource string s = Convert.ToBase64String((byte[])res); str = str.Replace(groups[0].Value, string.Format(HelpConst.EmbeddedImg, s)); } } return(str); }