Browse Source

Added AppendContainerNameToBasePath option to the file system blob provider.

pull/4105/head
Halil İbrahim Kalkan 6 years ago
parent
commit
e42a0b49fb
  1. 10
      framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs
  2. 9
      framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfiguration.cs
  3. 4
      framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProviderConfigurationNames.cs

10
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;
}

9
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)));
}
/// <summary>
/// Default value: true.
/// </summary>
public bool AppendContainerNameToBasePath
{
get => _containerConfiguration.GetConfigurationOrDefault(FileSystemBlobProviderConfigurationNames.AppendContainerNameToBasePath, true);
set => _containerConfiguration.SetConfiguration(FileSystemBlobProviderConfigurationNames.BasePath, value);
}
private readonly BlobContainerConfiguration _containerConfiguration;
public FileSystemBlobProviderConfiguration(BlobContainerConfiguration containerConfiguration)

4
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";
}
}
Loading…
Cancel
Save