//private static IConfigStore configStore = new ConfigStore();
        public static IAssetStorageManager GetStorageManager(string configCategory,string webUrl)
        {
            ConfigRepository configStore = new ConfigRepository(webUrl);
            var mediaConfig = configStore.GetAllConfigFromCategory(configCategory);
            string storageMethod = mediaConfig[MediaConfigKeys.AssetStorageMethod.ToString()];
            if ("SPLibrary".Equals(storageMethod, StringComparison.InvariantCultureIgnoreCase))
            {
                string mediaLibraryName = mediaConfig[MediaConfigKeys.AssetStorageLibraryName.ToString()];
                return new SPLibraryAssetStorageManager(webUrl, mediaLibraryName);
            }
            else if ("FileSystem".Equals(storageMethod, StringComparison.InvariantCultureIgnoreCase))
            {
                string storageFolderPath = mediaConfig[MediaConfigKeys.AssetStoragePushFolderPath.ToString()];
                string storageBaseAddress = mediaConfig[MediaConfigKeys.AssetStoragePullBaseAddress.ToString()];
                return new FileSystemAssetStorageManager(storageFolderPath,storageBaseAddress);
            }
            else if ("FTP".Equals(storageMethod, StringComparison.InvariantCultureIgnoreCase))
            {
                string ftpServerUrl = mediaConfig[MediaConfigKeys.AssetStorageFTPServerUrl.ToString()];
                string ftpServerUsername = mediaConfig[MediaConfigKeys.AssetStorageFTPServerUsername.ToString()];
                string ftpServerPassword = mediaConfig[MediaConfigKeys.AssetStorageFTPServerPassword.ToString()];
                string ftpServerPullAdress = mediaConfig[MediaConfigKeys.AssetStorageFTPServerPullAddress.ToString()];
                return new FTPAssetStorageManager(ftpServerUrl,ftpServerPullAdress,ftpServerUsername,ftpServerPassword);
            }
            else if ("AmazonS3".Equals(storageMethod, StringComparison.InvariantCultureIgnoreCase))
            {
                string amazonBucketName = mediaConfig[MediaConfigKeys.AssetStorageAmazonBucketName.ToString()];
                string amazonKeyName = mediaConfig[MediaConfigKeys.AssetStorageAmazonKeyName.ToString()];
                string amazonAccessKeyID = mediaConfig[MediaConfigKeys.AssetStorageAmazonAccessKeyID.ToString()];
                string amazonAccessSecretKeyID = mediaConfig[MediaConfigKeys.AssetStorageAmazonAccessSecretKeyID.ToString()];

                return new AmazonS3AssetStorageManager(amazonBucketName, amazonKeyName, amazonAccessKeyID, amazonAccessSecretKeyID);
            }
            else if ("AzureBlob".Equals(storageMethod, StringComparison.InvariantCultureIgnoreCase))
            {
                string azureAccountName = mediaConfig[MediaConfigKeys.AssetStorageAzureAccountName.ToString()];
                string azureAccountKey = mediaConfig[MediaConfigKeys.AssetStorageAzureAccountKey.ToString()];
                string azureBlobEnpoint = mediaConfig[MediaConfigKeys.AssetStorageAzureBlobEndpoint.ToString()];
                string azureContainer = mediaConfig[MediaConfigKeys.AssetStorageAzureContainer.ToString()];

                return new AzureStorageManager(azureAccountName, azureAccountKey, azureBlobEnpoint, azureContainer);
            }
            throw new ArgumentException(String.Format("Incorrect configuration Value '{0}' in ConfigStore for category '{1}' and key '{2}'. Supported options are: '{3}'",
               storageMethod, configCategory, MediaConfigKeys.AssetStorageMethod.ToString(), "AmazonS3|FileSystem|FTP|SPLibrary"));
        }
Example #2
0
        public static MediaConfig FromConfigStore(string webUrl)
        {
            ConfigRepository configRepo = new ConfigRepository(webUrl);
            var mediaConfigs = configRepo.GetAllConfigFromCategory("Media");

            var config = new MediaConfig();

            config.MediaAssetsListName = mediaConfigs[MediaConfigKeys.MediaAssetsListName.ToString()];
            config.TempLocationFolder = mediaConfigs[MediaConfigKeys.TempLocationFolder.ToString()];
            config.EncoderExePath = mediaConfigs[MediaConfigKeys.EncoderExePath.ToString()];
            config.SupportedAudioFormats = mediaConfigs[MediaConfigKeys.SuportedAudioFormats.ToString()];
            config.SupportedImageFormats = mediaConfigs[MediaConfigKeys.SupportedImageFormats.ToString()];
            config.SupportedVideoFormats = mediaConfigs[MediaConfigKeys.SupportedVideoFormats.ToString()];
            config.MaxImageSizeInMegaBytes = Convert.ToInt32(mediaConfigs[MediaConfigKeys.MaxImageSizeInMB.ToString()]);
            config.MaxAudioSizeInMegaBytes = Convert.ToInt32(mediaConfigs[MediaConfigKeys.MaxAudioSizeInMB.ToString()]);
            config.MaxVideoSizeInMegaBytes = Convert.ToInt32(mediaConfigs[MediaConfigKeys.MaxVideoSizeInMB.ToString()]);
            config.MaxAudioLengthMinutes = Convert.ToInt32(mediaConfigs[ MediaConfigKeys.MaxAudioLengthMinutes.ToString()]);
            config.MaxVideoLengthMinutes = Convert.ToInt32(mediaConfigs[ MediaConfigKeys.MaxVideoLengthMinutes.ToString()]);
            config.EncodeVideoFlag = Convert.ToBoolean(mediaConfigs[MediaConfigKeys.EncodeVideoFlag.ToString()]);
            config.DefaultAudioThumbnail = mediaConfigs[MediaConfigKeys.DefaultAudioThumbnail.ToString()];
            config.DefaultAudioPoster = mediaConfigs[MediaConfigKeys.DefaultAudioPoster.ToString()];
            return config;
        }