Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureBlobFileSystem"/> class
        /// from values in application settings.
        /// </summary>
        /// <param name="alias">The alias of the provider</param>
        public AzureBlobFileSystem(string alias)
        {
            string connectionString = ConfigurationManager.AppSettings[$"{ConnectionStringKey}:{alias}"];

            if (!string.IsNullOrWhiteSpace(connectionString))
            {
                string rootUrl = ConfigurationManager.AppSettings[$"{RootUrlKey}:{alias}"];
                if (string.IsNullOrWhiteSpace(rootUrl))
                {
                    throw new InvalidOperationException("Azure Storage Root URL is not defined in application settings. The " + RootUrlKey + " property was not defined or is empty.");
                }

                string containerName = ConfigurationManager.AppSettings[$"{ContainerNameKey}:{alias}"];
                if (string.IsNullOrWhiteSpace(containerName))
                {
                    containerName = "media";
                }

                string maxDays = ConfigurationManager.AppSettings[$"{MaxDaysKey}:{alias}"];
                if (string.IsNullOrWhiteSpace(maxDays))
                {
                    maxDays = "365";
                }

                string useDefaultRoute = ConfigurationManager.AppSettings[$"{UseDefaultRootKey}:{alias}"];
                if (string.IsNullOrWhiteSpace(useDefaultRoute))
                {
                    useDefaultRoute = "true";
                }

                string accessType = ConfigurationManager.AppSettings[$"{UsePrivateContainerKey}:{alias}"];
                if (string.IsNullOrWhiteSpace(accessType))
                {
                    accessType = "true";
                }

                this.FileSystem = AzureFileSystem.GetInstance(containerName, rootUrl, connectionString, maxDays, useDefaultRoute, accessType);
            }
            else
            {
                throw new InvalidOperationException("Unable to retrieve the Azure Storage configuration from the application settings. " + ConnectionStringKey + " was not defined or is empty.");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureBlobFileSystem"/> class.
 /// </summary>
 /// <param name="containerName">The container name.</param>
 /// <param name="rootUrl">The root url.</param>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param>
 /// <param name="useDefaultRoute">Whether to use the default "media" route in the url independent of the blob container.</param>
 /// <param name="usePrivateContainer">blob container can be private (no direct access) or public (direct access possible, default)</param>
 public AzureBlobFileSystem(string containerName, string rootUrl, string connectionString, string maxDays, string useDefaultRoute, string usePrivateContainer)
 {
     this.FileSystem = AzureFileSystem.GetInstance(containerName, rootUrl, connectionString, maxDays, useDefaultRoute, usePrivateContainer);
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureBlobFileSystem"/> class.
 /// </summary>
 /// <param name="containerName">The container name.</param>
 /// <param name="rootUrl">The root url.</param>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param>
 public AzureBlobFileSystem(string containerName, string rootUrl, string connectionString, string maxDays)
 {
     this.FileSystem = AzureFileSystem.GetInstance(containerName, rootUrl, connectionString, maxDays);
 }