Created
April 1, 2019 13:07
-
-
Save TheEskhaton/799aca469c281a43570ed4ee1a0523be to your computer and use it in GitHub Desktop.
kentico media module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Registers the custom module into the system | |
[assembly: RegisterModule(typeof(AzureMediaModule))] | |
public class AzureMediaModule : Module | |
{ | |
// Module class constructor, the system registers the module under the name "AzureMediaModule" | |
public AzureMediaModule() | |
: base("AzureMediaModule") | |
{ | |
} | |
// Contains initialization code that is executed when the application starts | |
protected override void OnInit() | |
{ | |
base.OnInit(); | |
if (bool.TryParse(WebConfigurationManager.AppSettings.Get("AzureStorageEnabled"), out bool enabled) | |
&& enabled) | |
{ | |
// Creates a new StorageProvider instance for Azure | |
var mediaProvider = StorageProvider.CreateAzureStorageProvider(); | |
// Specifies the target container | |
mediaProvider.CustomRootPath = WebConfigurationManager.AppSettings.Get("AzureStorageMediaRootPath"); | |
// Makes the container publicly accessible | |
mediaProvider.PublicExternalFolderObject = true; | |
// Maps a directory to the provider | |
StorageHelper.MapStoragePath($"~/{SiteContext.CurrentSiteName}/media/", mediaProvider); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment