Starts in:
1 DAY
20 HRS
34 MIN
46 SEC
Starts in:
1 D
20 H
34 M
46 S
Open Closed

Adding Volo.Abp.BlobStoring.Database to microservice #3265


User avatar
0
alirizaadiyahsi created
  • ABP Framework version: v5.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Angular Microservice

I added a new microservice that named FileManagerService and added database blob storing to it by using this command: abp add-module Volo.Abp.BlobStoring.Database.

All looks fine but when I trying to save files, provider is using AdminstrationServiceDB.

[Authorize(FileManagerServicePermissions.FileManager.Files.FilesDefault)]
public class FileAppService : ApplicationService, IFileAppService
{
    private IBlobContainer _fileContainer;
    private readonly IBlobContainerFactory _blobContainerFactory;

    public FileAppService(IBlobContainerFactory blobContainerFactory)
    {
        _blobContainerFactory = blobContainerFactory;
    }

    public async Task<BlobDto> GetBlobAsync(GetBlobRequestDto input)
    {
        var blob = await _fileContainer.GetAllBytesAsync(input.Name);

        return new BlobDto
        {
            Name = input.Name,
            Content = blob
        };
    }

    [Authorize(FileManagerServicePermissions.FileManager.Files.Create)]
    [Authorize(FileManagerServicePermissions.FileManager.Files.Edit)]
    public async Task SaveBlobAsync(CreateBlobInput input)
    {
        _fileContainer = _blobContainerFactory.Create("microservice-name");
        await _fileContainer.SaveAsync(input.Name, input.Content, true);
    }

How I configure blobContainer to use file-manager connection string, instead of using administration-service connection string?

And this is the file-manager-service connection strings in appsettings.json.

And DB


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you check this?

    https://docs.abp.io/en/commercial/latest/startup-templates/microservice/infrastructure#hosting

    Configure<AbpDbConnectionOptions>(options =>
    {
        options.Databases.Configure("FileManagementService", database =>
        {
            database.MappedConnections.Add("FileManagement");
        });
    });
    
  • User Avatar
    0
    alirizaadiyahsi created

    Hi @maliming I can't understand what you mean. I have no connection issues, actually. Each microservice can connect to its own DB via repos without issue. The problem is blobProvider is bypassing fileManagerConnectionString by administration-service. Repositories that are in blobProvider is connecting the administration service DB.

    I think I should configure blobStoringProvider to connect file-manager-service DB, but I can't find any solution about this.

    BTW, here is my connections:

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try this?

    options.Databases.Configure("FileManagerService", database =>
    {
        database.MappedConnections.Add("FileManagerService");
        database.MappedConnections.Add("AbpBlobStoring"); // add this line.
    });
    
  • User Avatar
    0
    alirizaadiyahsi created

    Hi @maliming, I removed blobStoring from project. We will no longer use this.

    Thanks for your helping and your time.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06