How to set the storage provider of a new album?

Posted by Community Admin on 04-Aug-2018 06:46

How to set the storage provider of a new album?

All Replies

Posted by Community Admin on 24-Jul-2014 00:00

Hi guys

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

Example:

//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.
librariesManager.RecompileAndValidateUrls(album);
 
//Save the changes.
librariesManager.SaveChanges();

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?

Posted by Community Admin on 24-Jul-2014 00:00

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,
Daniel

Posted by Community Admin on 03-Aug-2014 00:00

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

This thread is closed