Remove useless code in storage providers

This commit is contained in:
nicolas.dorier 2019-04-22 16:57:22 +09:00
parent 5100c36c06
commit 4ce0cb4b35
9 changed files with 6 additions and 91 deletions

View file

@ -14,11 +14,6 @@ namespace BTCPayServer.Storage.Services.Providers.AmazonS3Storage
return Storage.Models.StorageProvider.AmazonS3;
}
public override AmazonS3StorageConfiguration GetProviderConfiguration(StorageSettings configuration)
{
return configuration.Configuration.ParseAmazonS3StorageConfiguration();
}
protected override Task<IStorageProvider> GetStorageProvider(AmazonS3StorageConfiguration configuration)
{
return Task.FromResult<IStorageProvider>(new AmazonStorageProvider(configuration));

View file

@ -1,17 +0,0 @@
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Storage.Services.Providers.AmazonS3Storage.Configuration
{
public static class AmazonS3FileProviderServiceExtensions
{
public static AmazonS3StorageConfiguration ParseAmazonS3StorageConfiguration(this JObject jObject)
{
return jObject.ToObject<AmazonS3StorageConfiguration>();
}
public static JObject ConvertConfiguration(this AmazonS3StorageConfiguration configuration)
{
return JObject.FromObject(configuration);
}
}
}

View file

@ -14,12 +14,6 @@ namespace BTCPayServer.Storage.Services.Providers.AzureBlobStorage
{
return Storage.Models.StorageProvider.AzureBlobStorage;
}
public override AzureBlobStorageConfiguration GetProviderConfiguration(StorageSettings configuration)
{
return configuration.Configuration.ParseAzureBlobStorageConfiguration();
}
protected override Task<IStorageProvider> GetStorageProvider(AzureBlobStorageConfiguration configuration)
{
return Task.FromResult<IStorageProvider>(new AzureStorageProvider(configuration));

View file

@ -1,17 +0,0 @@
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Storage.Services.Providers.AzureBlobStorage.Configuration
{
public static class AzureBlobStorageFileProviderServiceExtensions
{
public static AzureBlobStorageConfiguration ParseAzureBlobStorageConfiguration(this JObject jObject)
{
return jObject.ToObject<AzureBlobStorageConfiguration>();
}
public static JObject ConvertConfiguration(this AzureBlobStorageConfiguration configuration)
{
return JObject.FromObject(configuration);
}
}
}

View file

@ -13,7 +13,7 @@ namespace BTCPayServer.Storage.Services.Providers
{
public abstract StorageProvider StorageProvider();
public virtual async Task<StoredFile> AddFile(IFormFile file, StorageSettings configuration)
public async Task<StoredFile> AddFile(IFormFile file, StorageSettings configuration)
{
//respect https://www.microsoftpressstore.com/articles/article.aspx?p=2224058&seqNum=8 in naming
var storageFileName = $"{Guid.NewGuid()}-{file.FileName.ToLowerInvariant()}";
@ -70,7 +70,11 @@ namespace BTCPayServer.Storage.Services.Providers
await provider.DeleteBlobAsync(providerConfiguration.ContainerName, storedFile.StorageFileName);
}
public abstract TStorageConfiguration GetProviderConfiguration(StorageSettings configuration);
public TStorageConfiguration GetProviderConfiguration(StorageSettings configuration)
{
return configuration.Configuration.ToObject<TStorageConfiguration>();
}
protected abstract Task<IStorageProvider> GetStorageProvider(TStorageConfiguration configuration);
}

View file

@ -1,17 +0,0 @@
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Storage.Services.Providers.FileSystemStorage.Configuration
{
public static class FileSystemFileProviderServiceExtensions
{
public static FileSystemStorageConfiguration ParseFileSystemStorageConfiguration(this JObject jObject)
{
return jObject.ToObject<FileSystemStorageConfiguration>();
}
public static JObject ConvertConfiguration(this FileSystemStorageConfiguration configuration)
{
return JObject.FromObject(configuration);
}
}
}

View file

@ -38,11 +38,6 @@ namespace BTCPayServer.Storage.Services.Providers.FileSystemStorage
return Storage.Models.StorageProvider.FileSystem;
}
public override FileSystemStorageConfiguration GetProviderConfiguration(StorageSettings configuration)
{
return configuration.Configuration.ParseFileSystemStorageConfiguration();
}
protected override Task<IStorageProvider> GetStorageProvider(FileSystemStorageConfiguration configuration)
{
return Task.FromResult<IStorageProvider>(

View file

@ -1,17 +0,0 @@
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Storage.Services.Providers.GoogleCloudStorage.Configuration
{
public static class GoogleCloudStorageFileProviderServiceExtensions
{
public static GoogleCloudStorageConfiguration ParseGoogleCloudStorageConfiguration(this JObject jObject)
{
return jObject.ToObject<GoogleCloudStorageConfiguration>();
}
public static JObject ConvertConfiguration(this GoogleCloudStorageConfiguration configuration)
{
return JObject.FromObject(configuration);
}
}
}

View file

@ -16,11 +16,6 @@ namespace BTCPayServer.Storage.Services.Providers.GoogleCloudStorage
return Storage.Models.StorageProvider.GoogleCloudStorage;
}
public override GoogleCloudStorageConfiguration GetProviderConfiguration(StorageSettings configuration)
{
return configuration.Configuration.ParseGoogleCloudStorageConfiguration();
}
protected override Task<IStorageProvider> GetStorageProvider(
GoogleCloudStorageConfiguration configuration)
{