More in this section

Forums / Developing with Sitefinity / How to set the storage provider of a new album?

How to set the storage provider of a new album?

3 posts, 0 answered
  1. Adam
    Adam avatar
    4 posts
    08 Jul 2014
    24 Jul 2014
    Link to this post

    Hi guys

    When I create a new album (image library) programmatically, it creates it using the default storage provider.


    //Create the album.
    album = librariesManager.CreateAlbum(albumId);
    //Set the properties of the album.
    album.Title = albumTitle;
    album.DateCreated = DateTime.UtcNow;
    album.LastModified = DateTime.UtcNow;
    album.UrlName = Regex.Replace(albumTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
    //Recompiles and validates the url of the album.
    //Save the changes.

    This creates a new image library set to use Database storage, if that is the default storage provider in the system.

     I need to set it to another file based storage provider I have created. I can't make this the default storage provider because it would cause problems elsewhere.

    Can you programmatically set the storage provider for a new album?

  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    18 Feb 2004
    24 Jul 2014 in reply to Adam
    Link to this post

    Hi Adam,

    You can lookup the StorageProvider you want to work with, like this:

    // Set the BlogStorageProvider to FileSystem (in case of large files)
    var blobStorageProvider = Config.Get<LibrariesConfig>().BlobStorage.Providers["FileSystem"];
    album.BlobStorageProvider = blobStorageProvider.Name;

    Hope this helps?

    Kind regards,

  3. Adam
    Adam avatar
    4 posts
    08 Jul 2014
    03 Aug 2014 in reply to Daniel Plomp
    Link to this post

    Thanks very much Daniel, I'll give this a shot!

3 posts, 0 answered