public async Task <FileContentResult> GetByContentHash(string buildConfig, string cdnConfig, string contenthash, string filename) { Console.WriteLine("[" + DateTime.Now + "] Serving preview of \"" + filename + "\" (" + contenthash + ") for build " + buildConfig + " and cdn " + cdnConfig); System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition { FileName = "preview", Inline = true }; Response.Headers[HeaderNames.ContentDisposition] = cd.ToString(); var fileBytes = await CASC.GetFile(buildConfig, cdnConfig, contenthash); var ext = Path.GetExtension(filename); var mime = GetMimeTypeByExt(ext); if (ext == ".blp") { using (var stream = new MemoryStream(fileBytes)) using (var outStream = new MemoryStream()) { var blpReader = new SereniaBLPLib.BlpFile(stream); var blp = blpReader.GetBitmap(0); blp.Save(outStream, ImageFormat.Png); fileBytes = outStream.ToArray(); } mime = "image/png"; } return(new FileContentResult(fileBytes, mime)); }
public FileContentResult GetByFileDataID(string buildConfig, string cdnConfig, uint filedataid, string filename) { Logger.WriteLine("Serving preview of \"" + filename + "\" for build " + buildConfig + " and cdn " + cdnConfig); System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition { FileName = "preview", Inline = true }; Response.Headers[HeaderNames.ContentDisposition] = cd.ToString(); var fileBytes = CASC.GetFile(buildConfig, cdnConfig, filedataid); var ext = Path.GetExtension(filename); var mime = GetMimeTypeByExt(ext); if (ext == ".blp") { using (var stream = new MemoryStream(fileBytes)) using (var outStream = new MemoryStream()) { var blpReader = new SereniaBLPLib.BlpFile(stream); var blp = blpReader.GetBitmap(0); blp.Save(outStream, ImageFormat.Png); fileBytes = outStream.ToArray(); } mime = "image/png"; } return(new FileContentResult(fileBytes, mime)); }
public async Task <FileContentResult> GetByFileDataID(string buildConfig, string cdnConfig, uint filedataid, string filename, byte mipmap = 0) { Logger.WriteLine("Serving preview of \"" + filename + "\" for build " + buildConfig + " and cdn " + cdnConfig); System.Net.Mime.ContentDisposition cd = new() { FileName = "preview", Inline = true }; Response.Headers[HeaderNames.ContentDisposition] = cd.ToString(); var fileBytes = await CASC.GetFile(buildConfig, cdnConfig, filedataid); var ext = Path.GetExtension(filename); var mime = GetMimeTypeByExt(ext); if (ext == ".blp") { using (var stream = new MemoryStream(fileBytes)) using (var outStream = new MemoryStream()) { var blpReader = new SereniaBLPLib.BlpFile(stream); var blp = blpReader.GetBitmap(mipmap); blp.Save(outStream, ImageFormat.Png); fileBytes = outStream.ToArray(); Response.Headers["X-WoWTools-Res-Width"] = blp.Width.ToString(); Response.Headers["X-WoWTools-Res-Height"] = blp.Height.ToString(); Response.Headers["X-WoWTools-AvailableMipMaps"] = blpReader.MipMapCount.ToString(); } mime = "image/png"; } return(new FileContentResult(fileBytes, mime)); }