private void DownloadFile(System.Web.HttpContext context, CmsContent content, String filename)
        {
            CmsContentField mimeTypeField = content.FindField("mimetype");
            string mimeType = "application/octet-stream";
            if (mimeTypeField != null)
                mimeType = mimeTypeField.Value;

            Data.Guid siteGuid = CurrentSite.Guid;
            ContentFileUploadImpl filehandler = new ContentFileUploadImpl();
            StorageFile fileinfo = filehandler.GetInfo(siteGuid, filename);

            context.Response.Clear();
            context.Response.ClearHeaders();
            context.Response.ClearContent();
            context.Response.ContentType = mimeType;
            context.Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
            context.Response.AppendHeader("Content-Length", fileinfo.Size.ToString());
            context.Response.AppendHeader("Content-Transfer-Encoding", "binary");
            context.Response.Expires = 60;
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Cache.SetMaxAge(TimeSpan.FromMinutes(0));
            filehandler.Read(siteGuid,filename,context.Response.OutputStream);

            context.Response.Flush();
            context.Response.Close();
            context.Response.End();
        }
Example #2
0
        public void Update(CmsContent item, Table table)
        {
            //Updating always unapproved the item
            item.IsApproved = false;

            //Save the filename, so we can restore it
            String filename = null;
            if (item.ContentType.IsFileType)
                filename = item.FindField("filename").Value;

            //Remove all of the existing items
            foreach (CmsContentField field in item.Fields)
            {
                if (!(field.Name.Equals("filename")) &&
                     !(field.Name.Equals("mimetype")))
                {
                    item.RemoveField(field);
                }
            }
            PopulateFields(item.SubscriptionId,table, item, filename);

            Save(item);
        }