How to set the storage provider of a new album?
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?
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
Thanks very much Daniel, I'll give this a shot!