filesystem storage - moving items from database storage prov

Posted by Community Admin on 03-Aug-2018 23:22

filesystem storage - moving items from database storage provider

All Replies

Posted by Community Admin on 17-Aug-2011 00:00

Hello All,

I am wanting to move a ton of images in Sitefinity 4 from libraries that are using the database storage provider to using the filesystem storage provider. Currently there is no way to switch a library from one provider to the other but if I move images/documents from one library to a filesystem library the files do get moved to the filesystem correctly.

It looks to me the the main hangup in this process would be any widget that are filtering based on library will need to point to the new library but all direct links work fine.

Does anyone have any additional experience with this? Troubles?

Posted by Community Admin on 22-Aug-2011 00:00

Hello Sacparker,

We are taking an iterative approach to developing the file system provider. The first iteration was to release the provider which allows you to create media content items on the file system. Our next iteration is to extend the provider to support Windows Azure. We have considered the tool to move items from one provider to another, however we have hit a roadblock there and decided that will implement this in a further iteration of the provider.

Your approach is actually what we would recommend for now and we don't know of any issues with it. If you find some, please let us know.

Additionally if you would go to writing code, we can provide you a code sample for moving only the content of images to a different blob storage provider, without changing its library (and thus URL).

All the best,
Radoslav Atanasov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 03-Sep-2011 00:00

Hi

If I change the default after adding images to the database storage, will what I have done to date persist and that all new uploads will go to the file storage and everything be ok?


Thanks

Cheers
Richard

Posted by Community Admin on 07-Sep-2011 00:00

Hi Richard Cross,

Yes, after changing the album storage to the file system, all new uploaded images will go to the file system, but the old images will stay in the database, because the storage provider is internally set per item, and everything should work fine.
Here is the code for changing the storage provider of a library and moving all library item to the new storage:

/// <summary>
/// Change the album BLOB Storage Provider and begins transfering album images to the BLOB storage of the album.
/// This might be a long time operation. If it doesn't finish for some reason, can be resumed.
/// </summary>
/// <param name="albumName">Name of the album.</param>
/// <param name="newBlobStorageProvider">The new BLOB storage provider.</param>
public static void BeginChangeAlbumBlobStorage(string albumName, string newBlobStorageProvider)
    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);
    foreach (var image in imagesToTransfer)
    
        manager.TransferItemStorage(image, newBlobStorageProvider);
        var liveImage = manager.GetLive(image);
        if (liveImage != null)
            manager.TransferItemStorage(liveImage, newBlobStorageProvider);
        var tempImage = manager.GetTemp(image);
        if (tempImage != null)
            manager.TransferItemStorage(tempImage, newBlobStorageProvider);
 
        manager.SaveChanges();
    

It is safe to execute it more than one time.

All the best,
Vlad
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This thread is closed