From e42a0b49fb6f91fd8ee5104822be96ca6ea38fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 26 May 2020 11:52:06 +0300 Subject: [PATCH] Added AppendContainerNameToBasePath option to the file system blob provider. --- .../BlobStoring/FileSystem/FileSystemBlobProvider.cs | 10 ++++++++-- .../FileSystem/FileSystemBlobProviderConfiguration.cs | 9 +++++++++ .../FileSystemBlobProviderConfigurationNames.cs | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs index 23b8ea45d6..4de039982f 100644 --- a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs +++ b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs @@ -61,7 +61,8 @@ namespace Volo.Abp.BlobStoring.FileSystem protected virtual string CalculateBlobFilePath(BlobProviderArgs args) { - var blobPath = args.Configuration.GetFileSystemConfiguration().BasePath; + var fileSystemConfiguration = args.Configuration.GetFileSystemConfiguration(); + var blobPath = fileSystemConfiguration.BasePath; if (args.TenantId == null) { @@ -72,7 +73,12 @@ namespace Volo.Abp.BlobStoring.FileSystem blobPath = Path.Combine(blobPath, "tenants", args.TenantId.Value.ToString("D")); } - blobPath = Path.Combine(blobPath, args.ContainerName, args.BlobName); + if (fileSystemConfiguration.AppendContainerNameToBasePath) + { + blobPath = Path.Combine(blobPath, args.ContainerName); + } + + blobPath = Path.Combine(blobPath, args.BlobName); return blobPath; } diff --git a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfiguration.cs b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfiguration.cs index f6a700d09a..442744c4f3 100644 --- a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfiguration.cs +++ b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfiguration.cs @@ -9,6 +9,15 @@ set => _containerConfiguration.SetConfiguration(FileSystemBlobProviderConfigurationNames.BasePath, Check.NotNullOrWhiteSpace(value, nameof(value))); } + /// + /// Default value: true. + /// + public bool AppendContainerNameToBasePath + { + get => _containerConfiguration.GetConfigurationOrDefault(FileSystemBlobProviderConfigurationNames.AppendContainerNameToBasePath, true); + set => _containerConfiguration.SetConfiguration(FileSystemBlobProviderConfigurationNames.BasePath, value); + } + private readonly BlobContainerConfiguration _containerConfiguration; public FileSystemBlobProviderConfiguration(BlobContainerConfiguration containerConfiguration) diff --git a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfigurationNames.cs b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfigurationNames.cs index 6670f6f76e..56991fa0ea 100644 --- a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfigurationNames.cs +++ b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfigurationNames.cs @@ -2,7 +2,7 @@ { public static class FileSystemBlobProviderConfigurationNames { - public const string BasePath = "BasePath"; - + public const string BasePath = "FileSystem.BasePath"; + public const string AppendContainerNameToBasePath = "FileSystem.AppendContainerNameToBasePath"; } } \ No newline at end of file