public void ProcessRequest(HttpContext context)
        {
            //TODO: Authorize this request!!!

            var file           = context.Request.Files["Filedata"];
            var userguid       = context.Request.Form["USERGUID"];
            var nodeguid       = context.Request.Form["NODEGUID"];
            var fileType       = context.Request.Form["FILETYPE"];
            var fileName       = context.Request.Form["FILENAME"];
            var umbracoVersion = context.Request.Form["UMBRACOVERSION"];

            var versions = new List <UmbracoVersion> {
                UmbracoVersion.DefaultVersion()
            };

            if (string.IsNullOrWhiteSpace(umbracoVersion) == false)
            {
                versions.Clear();
                versions = WikiFile.GetVersionsFromString(umbracoVersion);
            }

            if (string.IsNullOrWhiteSpace(userguid) == false &&
                string.IsNullOrWhiteSpace(nodeguid) == false &&
                string.IsNullOrWhiteSpace(fileType) == false &&
                string.IsNullOrWhiteSpace(fileName) == false)
            {
                WikiFile.Create(fileName, new Guid(nodeguid), new Guid(userguid), file, fileType, versions);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            HttpPostedFile file          = context.Request.Files["Filedata"];
            string         userguid      = context.Request.Form["USERGUID"];
            string         projectguid   = context.Request.Form["NODEGUID"];
            string         nodeId        = context.Request.Form["id"];
            string         fileType      = context.Request.Form["FILETYPE"];
            string         fileName      = context.Request.Form["FILENAME"];
            string         umbraoVersion = (context.Request.Form["UMBRACOVERSION"] != null) ? context.Request.Form["UMBRACOVERSION"] : "nan";
            string         dotNetVersion = (context.Request.Form["DOTNETVERSION"] != null) ? context.Request.Form["DOTNETVERSION"] : "nan";
            string         trustLevel    = (context.Request.Form["TRUSTLEVEL"] != null) ? context.Request.Form["TRUSTLEVEL"] : "nan";



            List <OurUmbraco.Wiki.BusinessLogic.UmbracoVersion> v = new List <OurUmbraco.Wiki.BusinessLogic.UmbracoVersion>()
            {
                OurUmbraco.Wiki.BusinessLogic.UmbracoVersion.DefaultVersion()
            };

            if (!string.IsNullOrEmpty(umbraoVersion))
            {
                v.Clear();
                v = WikiFile.GetVersionsFromString(umbraoVersion);
            }


            bool trust = false;

            if (trustLevel == "Medium")
            {
                trust = true;
            }


            if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(projectguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName))
            {
                var nodeListingProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider();
                var p = nodeListingProvider.GetListing(new Guid(projectguid));

                Member mem = new Member(new Guid(userguid));

                if (p.VendorId == mem.Id || Utils.IsProjectContributor(mem.Id, p.Id))
                {
                    var mediaProvider = new OurUmbraco.MarketPlace.Providers.MediaProvider();

                    var packageFileType = (FileType)Enum.Parse(typeof(FileType), (string)fileType, true);
                    // TODO: Don't know how else to get the bloody version
                    var version = UmbracoContext.Current.Application.Services.ContentService.GetById(p.Id).Version;
                    mediaProvider.CreateFile(fileName, version, mem.UniqueId, file, packageFileType, v, dotNetVersion, trust);
                }
                else
                {
                    umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner");
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            //TODO: Authorize this request!!!

            HttpPostedFile file          = context.Request.Files["Filedata"];
            string         userguid      = context.Request.Form["USERGUID"];
            string         nodeguid      = context.Request.Form["NODEGUID"];
            string         fileType      = context.Request.Form["FILETYPE"];
            string         fileName      = context.Request.Form["FILENAME"];
            string         umbraoVersion = context.Request.Form["UMBRACOVERSION"];
            string         dotNetVersion = context.Request.Form["DOTNETVERSION"];

            List <UmbracoVersion> v = new List <UmbracoVersion>()
            {
                UmbracoVersion.DefaultVersion()
            };

            if (!string.IsNullOrEmpty(umbraoVersion))
            {
                v.Clear();
                v = WikiFile.GetVersionsFromString(umbraoVersion);
            }

            if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(nodeguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName))
            {
                Document d   = new Document(Document.GetContentFromVersion(new Guid(nodeguid)).Id);
                Member   mem = new Member(new Guid(userguid));

                if (d.ContentType.Alias == "Project" && d.getProperty("owner") != null && (d.getProperty("owner").Value.ToString() == mem.Id.ToString() || Utils.IsProjectContributor(mem.Id, d.Id)))
                {
                    WikiFile.Create(fileName, new Guid(nodeguid), new Guid(userguid), file, fileType, v, dotNetVersion);

                    //the package publish handler will make sure we got the right versions info on the package node itself.
                    //ProjectsEnsureGuid.cs is the handler
                    if (fileType.ToLower() == "package")
                    {
                        d.Publish(new umbraco.BusinessLogic.User(0));
                        umbraco.library.UpdateDocumentCache(d.Id);
                    }
                }
                else
                {
                    umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner");
                }
            }
        }