// Protected Methods (1) 

        protected void Page_Load(object sender, EventArgs e)
        {
            string file        = Request.Params["fileid"];
            string fileName    = Request.Params["filename"];
            string delete      = Request.Params["delete"];
            string contentType = Request.Params["ct"];

            if (string.IsNullOrEmpty(file))
            {
                throw new HttpException(404, "HTTP/1.1 404 Not Found");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                fileName = file;
            }

            try
            {
                byte[] bytes;

                using (var epmLiveFileStore = new EPMLiveFileStore(SPContext.Current.Web))
                {
                    bytes = epmLiveFileStore.Get(file);

                    if (!string.IsNullOrEmpty(delete) && delete.Equals("1"))
                    {
                        epmLiveFileStore.Delete(file);
                    }
                }

                if (!string.IsNullOrEmpty(contentType))
                {
                    Response.ContentType = contentType;
                }

                Response.AddHeader("Content-Disposition", @"attachment;filename=""" + fileName + @"""");
                Response.Buffer = true;
                EnableViewState = false;

                Response.BinaryWrite(bytes);
                Response.End();
            }
            catch (Exception)
            {
                throw new HttpException(404, "HTTP/1.1 404 Not Found");
            }
        }
        // Protected Methods (3) 

        protected void OnSaveButtonClicked(object sender, EventArgs e)
        {
            SPUtility.ValidateFormDigest();

            byte[] pic;

            string resizeInfo = ResizeInfoField.Value;

            if (!string.IsNullOrEmpty(resizeInfo))
            {
                pic = ResizeImage(resizeInfo);
            }
            else
            {
                using (var fileStore = new EPMLiveFileStore(Web))
                {
                    pic = fileStore.Get(FileNameField.Value);
                }
            }

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                using (var spSite = new SPSite(Web.Site.ID))
                {
                    using (SPWeb spWeb = spSite.OpenWeb(Web.ID))
                    {
                        using (var fileStore = new EPMLiveFileStore(spWeb))
                        {
                            fileStore.Delete(FileNameField.Value);
                        }
                    }
                }
            });

            SavePicture(pic);
        }