Example #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="PID"></param>
    /// <returns></returns>
    public static Utility_3D.ConvertedModel GetAndConvertModel(String PID)
    {
        Utility_3D.ConverterOptions opts = (Utility_3D.ConverterOptions)HttpContext.Current.Session["options"];
        string NewModelFormat            = (string)HttpContext.Current.Session["format"];

        DataAccessFactory factory = new vwarDAL.DataAccessFactory();

        vwarDAL.IDataRepository vd = factory.CreateDataRepositorProxy();

        ContentObject co = vd.GetContentObjectById(PID, false, false);

        byte[] filedata = vd.GetContentFileData(PID, co.Location);

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + co.Location);
        HttpContext.Current.Response.ContentType = vwarDAL.DataUtils.GetMimeType(co.Location);

        Utility_3D _3d = new Utility_3D();

        _3d.Initialize(Website.Config.ConversionLibarayLocation);
        Utility_3D.Model_Packager pack  = new Utility_3D.Model_Packager();
        Utility_3D.ConvertedModel model = pack.Convert(new System.IO.MemoryStream(filedata), "temp.zip", NewModelFormat, opts);
        vd.Dispose();
        return(model);
    }
Example #2
0
        //write the json file to the response;
        public static void WriteJSONtoResponse(Stream stream, HttpContext context)
        {
            HttpResponse _response = context.Response;

            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, (int)stream.Length);
            Utility_3D _3d = new Utility_3D();

            _3d.Initialize(Website.Config.ConversionLibarayLocation);
            Utility_3D.Model_Packager pack  = new Utility_3D.Model_Packager();
            Utility_3D.ConvertedModel model = pack.Convert(new MemoryStream(buffer), "ThisShouldAlwaysBeZip.zip", "json");
            Ionic.Zip.ZipFile         zip   = Ionic.Zip.ZipFile.Read(model.data);
            _response.ContentType = "application/octet-stream";
            foreach (Ionic.Zip.ZipEntry ze in zip)
            {
                if (Path.GetExtension(ze.FileName) == ".json")
                {
                    MemoryStream mem = new MemoryStream();
                    ze.Extract(mem);
                    byte[] jsonbuffer = new byte[mem.Length];
                    mem.Seek(0, SeekOrigin.Begin);
                    mem.Read(jsonbuffer, 0, (int)mem.Length);
                    _response.BinaryWrite(jsonbuffer);
                    return;
                }
            }
        }
Example #3
0
 private void GenerateMissingTextureUI(Utility_3D.ConvertedModel model)
 {
     foreach (var texture in model.missingTextures)
     {
         var textureDialog = new Controls_MissingTextures {
             OldFile = texture
         };
         MissingTextureArea.Controls.Add(textureDialog);
     }
 }
Example #4
0
    protected void MissingTextureViewNextButton_Click(object sender, EventArgs e)
    {
        //get a reference to the model
        Utility_3D.ConvertedModel model = null;// GetModel();
        foreach (Control c in MissingTextureArea.Controls)
        {
            if (c is Controls_MissingTextures)
            {
                //loop over each dialog and find out if the user uploaded a file
                Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager();
                var uploadfile = (Controls_MissingTextures)c;
                //if they uploaded a file, push the file and model into the dll which will add the file
                if (uploadfile.FileName != "")
                {
                    pack.AddTextureToModel(ref model, uploadfile.FileContent, uploadfile.FileName);
                }
            }
        }
        //save the changes to the model
        //SetModel(model);
        //Get the DAL

        vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();;

        //Get the content object for this model
        ContentObject contentObj = dal.GetContentObjectById(ContentObjectID, false);

        using (MemoryStream stream = new MemoryStream())
        {
            //upload the modified datastream to the dal
            stream.Write(model.data, 0, model.data.Length);
            stream.Seek(0, SeekOrigin.Begin);
            dal.SetContentFile(stream, contentObj, contentObj.Location);
        }
        this.MultiView1.SetActiveView(this.ValidationView);
        dal.Dispose();
    }
Example #5
0
    public static FileStatus Convert()
    {
        Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager();
        Utility_3D _3d = new Utility_3D();

        _3d.Initialize(Website.Config.ConversionLibarayLocation);

        Utility_3D.ConvertedModel   model    = null;
        Utility_3D.ConverterOptions cOptions = new Utility_3D.ConverterOptions();
        cOptions.EnableTextureConversion(Utility_3D.ConverterOptions.PNG);
        cOptions.EnableScaleTextures(Website.Config.MaxTextureDimension);

        FileStatus status = (FileStatus)HttpContext.Current.Session["fileStatus"];

        if (status == null)
        {
            HttpContext.Current.Response.StatusCode = 500;
            return(new FileStatus("error", "error"));
        }
        using (FileStream stream = new FileStream(HttpContext.Current.Server.MapPath("~/App_data/" + status.hashname), FileMode.Open))
        {
            ContentObject tempFedoraObject = (ContentObject)HttpContext.Current.Session["contentObject"];
            try //convert the model
            {
                model = pack.Convert(stream, status.hashname, cOptions);

                HttpContext.Current.Session["contentTextures"]        = model.textureFiles;
                HttpContext.Current.Session["contentMissingTextures"] = model.missingTextures;

                Utility_3D.Parser.ModelData mdata = model._ModelData;
                tempFedoraObject.NumPolygons = mdata.VertexCount.Polys;
                tempFedoraObject.NumTextures = mdata.ReferencedTextures.Length;

                if (model._ModelData.VertexCount.Polys == 0 && model._ModelData.VertexCount.Verts == 0)
                {
                    status.converted = "false";
                    status.type      = FormatType.RECOGNIZED;
                }
                else
                {
                    status.converted = "true";
                    status.type      = FormatType.VIEWABLE;
                }


                HttpContext.Current.Session["fileStatus"] = status;

                tempFedoraObject.UpAxis = mdata.TransformProperties.UpAxis;
                if (mdata.TransformProperties.UnitMeters != 0)
                {
                    tempFedoraObject.UnitScale = System.Convert.ToString(mdata.TransformProperties.UnitMeters);
                }
                else
                {
                    tempFedoraObject.UnitScale = "1.0";
                }

                HttpContext.Current.Session["contentObject"] = tempFedoraObject;


                //Save the O3D file for the viewer into a temporary directory
                var tempfile = HttpContext.Current.Server.MapPath("~/App_Data/viewerTemp/" + status.hashname).Replace(".skp", ".zip");
                using (System.IO.FileStream savefile = new FileStream(tempfile, FileMode.Create))
                {
                    byte[] filedata = new Byte[model.data.Length];
                    model.data.CopyTo(filedata, 0);
                    savefile.Write(model.data, 0, (int)model.data.Length);
                }
                ConvertFileToO3D(HttpContext.Current, tempfile);
                if (!File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/viewerTemp/" + status.hashname).Replace(".skp", ".zip").Replace(".zip", ".o3d")))
                {
                    status.converted = "false";
                    status.type      = FormatType.RECOGNIZED;
                }
                var rootDir  = HttpContext.Current.Server.MapPath("~/App_Data/converterTemp/");
                var fileName = Path.Combine(rootDir, status.hashname.Replace(".skp", ".zip"));
                if (!Directory.Exists(rootDir))
                {
                    Directory.CreateDirectory(rootDir);
                }
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                File.Move(tempfile, fileName);
            }
            catch (Exception e) //Error while converting
            {
                stream.Close();
                //FileStatus.converted is set to false by default, no need to set


                status.msg = FileStatus.ConversionFailedMessage;  //Add the conversion failed message
                deleteTempFile(status.hashname);
                HttpContext.Current.Session["fileStatus"] = null; //Reset the FileStatus for another upload attempt
            }
        }
        return(status);
    }
Example #6
0
    protected void Step1NextButton_Click(object sender, EventArgs e)
    {
        //update
        if (IsModelUpload)
        {
            vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();;


            if (this.IsNew)
            {
                //create new & add to session
                ContentObject co = new ContentObject(dal);
                co.Title          = this.TitleTextBox.Text.Trim();
                co.UploadedDate   = DateTime.Now;
                co.LastModified   = DateTime.Now;
                co.Views          = 0;
                co.SubmitterEmail = Context.User.Identity.Name.Trim();
                dal.InsertContentObject(co);
                FedoraContentObject  = co;
                this.ContentObjectID = co.PID;
            }
            else
            {
                FedoraContentObject.Title = TitleTextBox.Text.Trim();
            }


            if (this.FedoraContentObject != null)
            {
                //asset type
                this.FedoraContentObject.AssetType = "Model";
                string newFileName = TitleTextBox.Text.ToLower().Replace(' ', '_') + Path.GetExtension(this.ContentFileUpload.PostedFile.FileName);
                //model upload
                Utility_3D.ConvertedModel model = null;
                if (this.ContentFileUpload.HasFile)
                {
                    string newOriginalFileName = "original_" + newFileName;

                    if (IsNew)
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            stream.Write(this.ContentFileUpload.FileBytes, 0, this.ContentFileUpload.FileBytes.Length);
                            FedoraContentObject.OriginalFileId = dal.SetContentFile(stream, FedoraContentObject.PID, newOriginalFileName);
                        }
                    }
                    else
                    {
                        //Update the original file
                        dal.UpdateFile(this.ContentFileUpload.FileBytes, FedoraContentObject.PID, FedoraContentObject.OriginalFileName, newOriginalFileName);
                    }
                    FedoraContentObject.OriginalFileName = newOriginalFileName;

                    Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager();
                    Utility_3D _3d = new Utility_3D();
                    Utility_3D.ConverterOptions cOptions = new Utility_3D.ConverterOptions();
                    cOptions.EnableTextureConversion(Utility_3D.ConverterOptions.PNG);
                    cOptions.EnableScaleTextures(Website.Config.MaxTextureDimension);
                    _3d.Initialize(Website.Config.ConversionLibarayLocation);

                    string UploadedFilename = newFileName;
                    if (Path.GetExtension(UploadedFilename) != ".zip")
                    {
                        UploadedFilename = Path.ChangeExtension(newFileName, ".zip");
                    }

                    try
                    {
                        model = pack.Convert(this.ContentFileUpload.PostedFile.InputStream, this.ContentFileUpload.PostedFile.FileName, cOptions);
                    }
                    catch
                    {
                        Response.Redirect(Page.ResolveClientUrl("~/Public/Model.aspx?ContentObjectID=" + this.ContentObjectID));
                    }


                    var    displayFilePath   = "";
                    string convertedFileName = newFileName.Replace(Path.GetExtension(newFileName).ToLower(), ".zip");
                    if (this.ContentFileUpload.HasFile)
                    {
                        using (Stream stream = new MemoryStream())
                        {
                            stream.Write(model.data, 0, model.data.Length);
                            stream.Seek(0, SeekOrigin.Begin);
                            FedoraContentObject.Location = UploadedFilename;
                            //FedoraContentObject.DisplayFileId =
                            dal.SetContentFile(stream, FedoraContentObject, UploadedFilename);
                        }
                    }
                    else
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            stream.Write(model.data, 0, model.data.Length);
                            stream.Seek(0, SeekOrigin.Begin);
                            dal.SetContentFile(stream, FedoraContentObject, UploadedFilename);
                            FedoraContentObject.Location = UploadedFilename;
                        }
                    }
                    FedoraContentObject.Location = convertedFileName;

                    if (model.type != "UNKNOWN")
                    {
                        string optionalPath   = (newFileName.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/";
                        string pathToTempFile = "~/App_Data/" + optionalPath;

                        string destPath = Path.Combine(Context.Server.MapPath(pathToTempFile), newFileName);

                        System.IO.FileStream savefile = new FileStream(destPath, FileMode.OpenOrCreate);
                        byte[] filedata = new Byte[model.data.Length];
                        model.data.CopyTo(filedata, 0);
                        savefile.Write(model.data, 0, (int)model.data.Length);
                        savefile.Close();

                        string outfilename       = Context.Server.MapPath("~/App_Data/viewerTemp/") + newFileName.Replace(".zip", ".o3d");
                        string convertedtempfile = ConvertFileToO3D(destPath, outfilename);



                        displayFilePath = FedoraContentObject.DisplayFile;
                        string o3dFileName = newFileName.Replace(Path.GetExtension(newFileName).ToLower(), ".o3d");
                        if (this.ContentFileUpload.HasFile)
                        {
                            using (FileStream stream = new FileStream(convertedtempfile, FileMode.Open))
                            {
                                FedoraContentObject.DisplayFileId = dal.SetContentFile(stream, FedoraContentObject, o3dFileName);
                            }
                        }
                        else
                        {
                            using (MemoryStream stream = new MemoryStream())
                            {
                                stream.Write(filedata, 0, filedata.Length);
                                stream.Seek(0, SeekOrigin.Begin);
                                dal.SetContentFile(stream, FedoraContentObject, UploadedFilename);
                                FedoraContentObject.DisplayFile = Path.GetFileName(FedoraContentObject.DisplayFile);
                            }
                        }
                        FedoraContentObject.DisplayFile = o3dFileName;
                    }
                    else
                    {
                        FedoraContentObject.DisplayFile = string.Empty;
                    }


                    FedoraContentObject.UnitScale   = model._ModelData.TransformProperties.UnitMeters.ToString();
                    FedoraContentObject.UpAxis      = model._ModelData.TransformProperties.UpAxis;
                    FedoraContentObject.NumPolygons = model._ModelData.VertexCount.Polys;
                    FedoraContentObject.NumTextures = model._ModelData.ReferencedTextures.Length;

                    PopulateValidationViewMetadata(FedoraContentObject);
                }

                //upload thumbnail
                if (this.ThumbnailFileUpload.HasFile)
                {
                    int length = (int)this.ThumbnailFileUpload.PostedFile.InputStream.Length;

                    if (IsNew || FedoraContentObject.ScreenShot == "")// order counts here have to set screenshot id after the update so we can find the correct dsid
                    {
                        this.FedoraContentObject.ScreenShot = "screenshot.png";
                    }

                    FedoraContentObject.ScreenShotId = dal.SetContentFile(this.ThumbnailFileUpload.PostedFile.InputStream, this.FedoraContentObject, FedoraContentObject.ScreenShot);

                    string ext = new FileInfo(ThumbnailFileUpload.PostedFile.FileName).Extension.ToLower();
                    System.Drawing.Imaging.ImageFormat format;

                    if (ext == ".png")
                    {
                        format = System.Drawing.Imaging.ImageFormat.Png;
                    }
                    else if (ext == ".jpg")
                    {
                        format = System.Drawing.Imaging.ImageFormat.Jpeg;
                    }
                    else if (ext == ".gif")
                    {
                        format = System.Drawing.Imaging.ImageFormat.Gif;
                    }
                    else
                    {
                        ScreenshotValidator.Visible = true;
                        ScreenshotValidator.Text    = "Nice job generating a POST request without the interface. Don't you feel special?";
                        return;
                    }

                    //Avoid wasting space by removing old thumbnails
                    //if (!String.IsNullOrEmpty(FedoraContentObject.ThumbnailId))
                    //   File.Delete("~/thumbnails/" + FedoraContentObject.ThumbnailId);

                    //Use the original file bytes to remain consistent with the new file upload ID creation for thumbnails
                    FedoraContentObject.ThumbnailId = Website.Common.GetFileSHA1AndSalt(ThumbnailFileUpload.PostedFile.InputStream) + ext;

                    //using (FileStream outFile = new FileStream(HttpContext.Current.Server.MapPath("~/thumbnails/" + FedoraContentObject.ThumbnailId), FileMode.Create))
                    //   Website.Common.GenerateThumbnail(ThumbnailFileUpload.PostedFile.InputStream, outFile, format);
                }

                //creative commons license url
                if (this.CCLicenseDropDownList.SelectedItem != null && this.CCLicenseDropDownList.SelectedValue != "None")
                {
                    this.FedoraContentObject.CreativeCommonsLicenseURL = this.CCLicenseDropDownList.SelectedValue.Trim();
                }

                //Require Resubmit Checkbox
                FedoraContentObject.RequireResubmit = this.RequireResubmitCheckbox.Checked;

                //developer logo
                this.UploadDeveloperLogo(dal, this.FedoraContentObject);

                //developer name
                if (!string.IsNullOrEmpty(this.DeveloperNameTextBox.Text))
                {
                    this.FedoraContentObject.DeveloperName = this.DeveloperNameTextBox.Text.Trim();
                }

                //sponsor logo
                this.UploadSponsorLogo(dal, this.FedoraContentObject);


                //sponsor name
                if (!string.IsNullOrEmpty(this.SponsorNameTextBox.Text))
                {
                    this.FedoraContentObject.SponsorName = this.SponsorNameTextBox.Text.Trim();
                }

                //artist name
                if (!string.IsNullOrEmpty(this.ArtistNameTextBox.Text))
                {
                    this.FedoraContentObject.ArtistName = this.ArtistNameTextBox.Text.Trim();
                }

                //format
                if (!string.IsNullOrEmpty(this.FormatTextBox.Text))
                {
                    this.FedoraContentObject.Format = this.FormatTextBox.Text.Trim();
                }


                //description
                if (!string.IsNullOrEmpty(this.DescriptionTextBox.Text))
                {
                    this.FedoraContentObject.Description = this.DescriptionTextBox.Text.Trim();
                }

                //more information url
                if (!string.IsNullOrEmpty(this.MoreInformationURLTextBox.Text))
                {
                    this.FedoraContentObject.MoreInformationURL = this.MoreInformationURLTextBox.Text.Trim();
                }

                //keywords
                string cleanTags = "";
                foreach (string s in KeywordsTextBox.Text.Split(','))
                {
                    cleanTags += s.Trim() + ",";
                }
                cleanTags = HttpContext.Current.Server.HtmlEncode(cleanTags.Trim(','));
                this.FedoraContentObject.Keywords = cleanTags;
            }

            dal.UpdateContentObject(FedoraContentObject);
            if (IsNew)
            {
                PermissionsManager perm = new PermissionsManager();
                perm.SetModelToGroupLevel(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], FedoraContentObject.PID, vwarDAL.DefaultGroups.AllUsers, ModelPermissionLevel.Fetchable);
                perm.SetModelToGroupLevel(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], FedoraContentObject.PID, vwarDAL.DefaultGroups.AnonymousUsers, ModelPermissionLevel.Searchable);
                perm.Dispose();
            }
            SetModelDisplay();
            this.PopulateValidationViewMetadata(FedoraContentObject);
            this.MultiView1.SetActiveView(this.ValidationView);
            var admins = UserProfileDB.GetAllAdministrativeUsers();
            foreach (DataRow row in admins.Rows)
            {
                var url = Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, this.ResolveUrl(Website.Pages.Types.FormatModel(this.ContentObjectID)));
                Website.Mail.SendModelUploaded(FedoraContentObject);
            }
            dal.Dispose();
        }
    }
Example #7
0
    public static JsonWrappers.AdvancedDownloadPreviewSettings ViewButton_Click(string PID, bool bConvert, bool bConvertTextures, bool bResizeTextures, bool bReducePolys, string NewModelFormat, string NewTextureFormat, int NewTextureSize, float PolygonThresh,
                                                                                bool Smoothing, bool IgnoreBoundry, float MaxError, float MaxEdgeLength, string mode)
    {
        if (!bConvert)
        {
            NewModelFormat = ".dae";
        }

        Utility_3D.ConverterOptions opts = new Utility_3D.ConverterOptions();
        if (bConvertTextures)
        {
            opts.EnableTextureConversion(NewTextureFormat);
        }
        if (bResizeTextures)
        {
            opts.EnableScaleTextures(NewTextureSize);
        }
        if (bReducePolys)
        {
            opts.EnablePolygonReduction(PolygonThresh);
        }

        opts.SetPolygonReductionSmoothing(Smoothing);
        opts.SetPolygonReductionMaxLength(MaxEdgeLength);
        opts.SetPolygonReductionMaxError(MaxError);
        if (mode == "Simple")
        {
            opts.SetPolygonReductionModeSimple();
        }
        else
        {
            opts.SetPolygonReductionModeComplex();
        }

        HttpContext.Current.Session["options"] = opts;
        HttpContext.Current.Session["format"]  = NewModelFormat;

        // string PID = HttpContext.Current.Request.QueryString["ContentObjectID"];
        DataAccessFactory factory = new vwarDAL.DataAccessFactory();

        vwarDAL.IDataRepository vd = factory.CreateDataRepositorProxy();

        ContentObject co = vd.GetContentObjectById(PID, false, false);


        JsonWrappers.AdvancedDownloadPreviewSettings jsReturnParams = new JsonWrappers.AdvancedDownloadPreviewSettings();
        jsReturnParams.FlashLocation = co.Location;

        Utils.FileStatus currentStatus = new Utils.FileStatus("", Utils.FormatType.UNRECOGNIZED);

        //tempFedoraCO.DisplayFile = currentStatus.filename.Replace("zip", "o3d").Replace("skp", "o3d");
        currentStatus.filename = co.Location;
        currentStatus.hashname = co.Location;

        jsReturnParams.IsViewable     = true;
        jsReturnParams.BasePath       = "../Public/";
        jsReturnParams.BaseContentUrl = "Model.ashx?temp=true&file=";
        jsReturnParams.O3DLocation    = currentStatus.hashname.ToLower().Replace("zip", "o3d").Replace("skp", "o3d");
        jsReturnParams.FlashLocation  = currentStatus.hashname;
        jsReturnParams.ShowScreenshot = true;
        jsReturnParams.UpAxis         = co.UpAxis;
        jsReturnParams.UnitScale      = co.UnitScale;

        string optionalPath   = (co.Location.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/";
        string pathToTempFile = "~/App_Data/" + optionalPath + co.Location;

        using (FileStream stream = new FileStream(HttpContext.Current.Server.MapPath(pathToTempFile), FileMode.Create, FileAccess.Write))
        {
            Utility_3D.ConvertedModel model = GetAndConvertModel(PID);
            byte[] data = model.data;
            Utility_3D.ConvertedModel model2 = (new Utility_3D.Model_Packager()).Convert(new MemoryStream(model.data), "test.zip");
            jsReturnParams.Polygons = model2._ModelData.VertexCount.Polys;
            stream.Write(data, 0, data.Length);
            stream.Close();
        }



        HttpContext.Current.Session["contentObject"] = co;
        vd.Dispose();

        return(jsReturnParams);

        // HttpContext.Current.Response.BinaryWrite(GetAndConvertModel().data);
    }
Example #8
0
        //Resolve a missing texture reference
        public string UploadMissingTexture(byte[] indata, string pid, string filename, string key)
        {
            if (!CheckKey(key))
                return null;
            pid = pid.Replace('_', ':');

            //Get the content object
            vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false);

            //Check the permissions
            if (!DoValidate(Security.TransactionType.Modify, pid))
            {
                ReleaseRepo();
                return "";
            }

            //Check that the file they are attempting to replace is actually missing
            vwarDAL.Texture found = null; ;
            foreach (vwarDAL.Texture i in co.MissingTextures)
            {
                if (i.mFilename.ToLower() == filename.ToLower())
                {
                    found = i;
                }
            }
            //If they are updating a texture that is missing

            if (found != null)
            {
                //Remove it from the list of missing textures
                co.RemoveMissingTexture(filename.ToLower());

                //The model converter class can be used to insert the file into the zip
                Utility_3D.Model_Packager _pack = new Utility_3D.Model_Packager();
                Utility_3D.ConvertedModel model = new Utility_3D.ConvertedModel();
                Stream sdata = co.GetContentFile();
                byte[] data = new byte[sdata.Length];
                sdata.Read(data, 0, (int)sdata.Length);

                //Insert the content file into a Model, and call the Add function
                model.data = data;
                _pack.AddTextureToModel(ref model, new MemoryStream(indata), filename.ToLower());

                //Overwrite the existing contentfile with the new one that contains the new texture
                co.SetContentFile(new MemoryStream(model.data), "content.zip");
                ReleaseRepo();
                return "Ok";
            }
            ReleaseRepo();
            //Need to come up with a nice set of return codes
            return "This texture is not a missing texture";
        }