Hello,
I am trying to change the storage provider from default to file system, for which I am configuring AbpBlobStoringOptions in my HttpApiHost module, And i am storing the path in Abpsettings table and i want to access the path using ISettingProvider, but the problem is I can't Inject ISettingProvider in the constructor because the module requires a parameterless constructor to create the instance. so can you help me with providing a way to retrieve the path from the abpsettings table in my hostmodule.
Thank you.
1 Answer(s)
-
0
Hi,
let me rephrase just to ensure that I understood your issue.
- You want to use Blob Storage with the file system provider
- Instead of setting a hardcoded base path (like described here https://docs.abp.io/en/abp/latest/Blob-Storing-File-System#configuration) you want to use a value which is determined at runtime
You can archieve that by implementing your own
IBlobFilePathCalculator
as described here: https://docs.abp.io/en/abp/latest/Blob-Storing-File-System#file-path-calculationAn example would look as follows:
using System.IO; using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.FileSystem; using Volo.Abp.Settings; namespace app; public class MyBlobFilePathCalculator : IBlobFilePathCalculator { private readonly ISettingProvider _settingProvider; public MyBlobFilePathCalculator(ISettingProvider settingProvider) { _settingProvider = settingProvider; } public string Calculate(BlobProviderArgs args) { string basePath = _settingProvider.GetOrNullAsync("MySetting").Result; return Path.Combine(basePath, args.ContainerName, args.BlobName); } }