Connecting Kentico to a Rackspace CDN

Tom Grable asked on November 7, 2019 19:33

We would like to connect our Kentico 12 MVC application to a remote CDN on Rackspace. I found an article on how to set up the CustomFileSystemProvider project, but it doesn't contain any code to do this.

Has anyone else done this? Can you make the code available to do that?

Recent Answers


Michal Samuhel answered on November 8, 2019 09:48

Hello Tom,

Do you mean article in documentation?

This provider allows you to map physical folders to for example rackspace. All this with help of custom file system provider . While this code:

// Creates a new StorageProvider instance using the custom 'CustomFileSystemProvider' assembly
    var customMediaProvider = new StorageProvider("custom", "CustomFileSystemProvider");

    // Maps a directory to the provider
    StorageHelper.MapStoragePath("~/MySite/Media/", customMediaProvider);

Allows you to choose which provider will be used and which part of application path will be mapped to this provider. Provider code:

// Specifies the target root directory. The provider creates the relative path of the mapped folders within the given directory.
    mediaProvider.CustomRootPath = @"D:\CustomMediaRoot";

    // Maps a directory to the provider
    StorageHelper.MapStoragePath("~/MySite/Media/", mediaProvider);

Maps its own path to shared drive and also maps part of application path to 3rd party. So by this, anytime a file in ~/MySite/Media/ folder will be requested, application will not use its own path, but it will try to locate files on @"D:\CustomMediaRoot". Similarly you can map files to rackspace. On rackspace part, you need to create Cloud files container which will provide you with unique URL, that you will be using to upload and serve files.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.