示例#1
0
        public void TransmitImage(string filename)
        {
            SizingOptions options = SizingOptions.Parse(filename);

            HttpContext.Current.Response.ContentType = "image/jpeg";
            if (WebUtility.RawQueryString == "nocache")
            {
                ResizeImage(options, HttpContext.Current.Response.OutputStream);
                HttpContext.Current.Response.End();
            }
            else
            {
                if (!File.Exists(options.PhysicalPath))
                {
                    ResizeImage(options);
                }
                HttpContext.Current.Response.TransmitFile(options.PhysicalPath);
            }
        }
示例#2
0
        public void TransmitRequestedImage()
        {
            // note: if processing ever gets this far, we definitely don't have a cached version
            // of this file, or the ContentCache would have served it up by now.

            FileInfo      info    = new FileInfo(SprocketPath.Physical);
            SizingOptions options = SizingOptions.Parse(info.Name);

            HttpContext.Current.Response.ContentType = "image/jpeg";
            if (WebUtility.RawQueryString == "nocache")
            {
                ResizeImage(options, HttpContext.Current.Response.OutputStream);
                HttpContext.Current.Response.End();
            }
            else
            {
                MemoryStream stream = new MemoryStream();
                ResizeImage(options, stream);
                string path = ContentCache.Store("Sprocket.Web.FileManager.CachedImage." + options.SprocketFileID + "." + options.Filename, null, false, SprocketPath.Value, "image/jpeg", stream);
                HttpContext.Current.Response.TransmitFile(path);
            }
        }