public void InitializeBlobProviders(ConnectionStringOptions connectionStrings) { // add built-in provider manually if necessary if (!BlobProviders.Values.Any(bp => bp is IBuiltInBlobProvider)) { BlobProviders.AddProvider(new BuiltInBlobProvider(Options.Create(DataOptions.GetLegacyConfiguration()), Options.Create(connectionStrings))); } if (BlobProviderSelector == null) { BlobProviderSelector = new BuiltInBlobProviderSelector(BlobProviders, null, Options.Create(BlobStorageOptions.GetLegacyConfiguration())); } if (BlobMetaDataProvider == null) { BlobMetaDataProvider = new MsSqlBlobMetaDataProvider(BlobProviders, Options.Create(DataOptions.GetLegacyConfiguration()), Options.Create(BlobStorageOptions.GetLegacyConfiguration()), Options.Create(connectionStrings)); } // assemble the main api instance if necessary (for tests) if (BlobStorage == null) { BlobStorage = new ContentRepository.Storage.Data.BlobStorage( BlobProviders, BlobProviderSelector, BlobMetaDataProvider, Options.Create(BlobStorageOptions.GetLegacyConfiguration())); } BlobStorage.Initialize(); }
public virtual IBlobProvider Get([NotNull] string containerName) { Check.NotNull(containerName, nameof(containerName)); var configuration = ConfigurationProvider.Get(containerName); if (!BlobProviders.Any()) { throw new AbpException("No BLOB Storage provider was registered! At least one provider must be registered to be able to use the BLOB Storing System."); } if (configuration.ProviderType == null) { throw new AbpException("No BLOB Storage provider was used! At least one provider must be configured to be able to use the BLOB Storing System."); } foreach (var provider in BlobProviders) { if (ProxyHelper.GetUnProxiedType(provider).IsAssignableTo(configuration.ProviderType)) { return(provider); } } throw new AbpException( $"Could not find the BLOB Storage provider with the type ({configuration.ProviderType.AssemblyQualifiedName}) configured for the container {containerName} and no default provider was set." ); }
public void ResetBlobProviders(ConnectionStringOptions connectionStrings) { BlobStorage = null; BlobProviderSelector = null; BlobMetaDataProvider = null; BlobProviders.Clear(); // add default internal blob provider BlobProviders.AddProvider(new BuiltInBlobProvider(Options.Create(DataOptions.GetLegacyConfiguration()), Options.Create(connectionStrings))); }