Store files in DB (in different galleries)

  •  11-01-2005, 10:53 AM

    Store files in DB (in different galleries)

    I'm evaluating the CuteEditor in VS.Net 2005 and have a question about 'store images in db'.
    I downloaded the sample 'UseSql' from your website and wanted to extend it, so that you can define the gallery-path where the images are stored (see the following code below).

    I want to create the directory if it does not yet exist.
    I can do this directly in the db-table 'fsitems' or with the 'SqlFileStorage'-Class.
    I tried the second solution, but I cannot create an instance of this class, there is the exception: 'editor setting not found'.
    What can I do?

    Thanks,
    Björn.

    private void Page_Load(object sender, System.EventArgs e)
    {
      // set the connection string    
      CustomFileProvider.SqlSample.SqlFileStorage.ConnectionString = 
        @"server=.;uid=test;pwd=test;Trusted_Connection=no;database=test";


      Editor1.Setting["CuteEditorFileStorageType"]=typeof(SqlFileStorage).AssemblyQualifiedName;
      Editor1.Setting["DownFile"]=ResolveUrl("DownFile.Aspx");


      // set default gallery path
      Editor1.SetSecurityGalleryPath("/");


      // override default gallery path if there is defined another one as url-parameter
      string gallerypath = Request.QueryString["gallerypath"];
      if (!string.IsNullOrEmpty(gallerypath))
      {
        // create storage
        SqlFileStorage storage = new SqlFileStorage(HttpContext.Current); 
        // ==> exception: editor setting not found!!!


        // split gallerypath => dirPath, dirName
        // "/100" ==> "/", "100"
        string dirPath = gallerypath.Substring(0, gallerypath.LastIndexOf('/') + 1);
        string dirName = gallerypath.Substring(gallerypath.LastIndexOf('/') + 1);
             
        // requested path exists?
        string dirText = storage.GetDirectoryText(dirPath);
        if (string.IsNullOrEmpty(dirText))
        {
            storage.CreateDirectory(dirPath, dirName);
        }
        // set the requested path
        Editor1.SetSecurityGalleryPath(gallerypath);
      }
    } // Page_Load
View Complete Thread