BlobStorageManager provides general blob storage facilities. When working with blobs you use LibrariesManager to get the album that you are to alter. Blob storage providers configuration is stored in the LibrariesConfig file.
The following sample creates a blob storage provider:
This sample creates an album with the specified blob storage provider and uploads there the images from the specified path. The method parameters are the root folder that contains the images and the name of the blob storage provider.
First, you get the LibrariesManager and create the new album based on the root folder name. Then, you set the blob storage provider for the new album. You can find the available storage providers inConfig.Get<LibrariesConfig>().BlobStorage.Providers or BlobStorageManager.ProvidersCollection. Finally, you upload the images from the folder in the album that automatically stores all the images in the location pointed by the blob storage provider.
This sample changes the album blob storage provider and begins transferring album images to the new blob storage location of the album.
NOTE: This could be a long time operation. If it does not finish for some reason, it can be resumed.
The method parameters are the album name and the name of the new blob storage provider for the album.
var manager = LibrariesManager.GetManager();
var album = manager.GetAlbums().Where(i => i.UrlName == albumName).FirstOrDefault();
album.BlobStorageProvider = newBlobStorageProvider;
var imagesToTransfer = album.Images.Where(i => i.Status == ContentLifecycleStatus.Master && i.BlobStorageProvider != newBlobStorageProvider);
var liveImage = manager.GetLive(image);
var tempImage = manager.GetTemp(image);
First, you get the LibrariesManager and the album based on albumName. Then, you get all images that have a blob storage provider different from the new provider and, finally, transfer them to the new location pointed by newBlobStorageProvider.
This sample moves all images from one album to another. If the target album uses different blob storage, the images will be transferred to the target album storage.
The method parameters are the names for the source and target albums.
var sourceAlbum = manager.GetAlbums().Where(i => i.UrlName == sourceAlbumName).FirstOrDefault();
var targetAlbum = manager.GetAlbums().Where(i => i.UrlName == targetAlbumName).FirstOrDefault();
var imagesToMove = sourceAlbum.Images.Where(i => i.Status == ContentLifecycleStatus.Master).ToList();
First, you get the LibrariesManager and the source and target albums based on sourceAlbumName and targetAlbumName. Then, you change the parent for every item to the target album.
Back To Top