Open Closed

Configuring Blob Storing Using File system as the storage provider. #5131


User avatar
0
ed_developer2 created

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.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    jfistelmann created

    Hi,

    let me rephrase just to ensure that I understood your issue.

    1. You want to use Blob Storage with the file system provider
    2. 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-calculation

    An 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);
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.