- 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)
-
0
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"); }); });
-
0
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:
-
0
hi
Can you try this?
options.Databases.Configure("FileManagerService", database => { database.MappedConnections.Add("FileManagerService"); database.MappedConnections.Add("AbpBlobStoring"); // add this line. });
-
0
Hi @maliming, I removed blobStoring from project. We will no longer use this.
Thanks for your helping and your time.