- ABP Framework version: v4.2.2
- UI type: Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
I am using the FileManagement module to store files in Aws S3 using the AwsBlobProvider.
We need to set the correct Content Type (Mime Type) on Aws when the files are stored. The correct content type is stored in the local DB and looking at the code there is a MimeType property on the FileDescriptor object passed to the IFileDescriptorRepository.InsertAsync() method. I've created my own AwsBlobProvider that can accept ContentType but how do I intercept the IFileDescriptorRepository.InsertAsync() to insert the MimeType?
Thanks, Dean
2 Answer(s)
- 
    0Hi @dean_ve The File Management module stores blob and creates it's entity in the FileManager, FileManager.cspublic class FileManager : DomainService, IFileManager { .... protected IBlobContainer<FileManagementContainer> BlobContainer { get; } .... public virtual async Task<FileDescriptor> CreateAsync( string name, string mimeType, byte[] content, Guid? directoryId = null, Guid? tenantId = null, bool overrideExisting = false) { var fileDescriptor = await SaveFileDescriptorAsync(name, mimeType, content.Length, directoryId, tenantId, overrideExisting); await BlobContainer.SaveAsync(fileDescriptor.Id.ToString(), content, true); return fileDescriptor; }As you see at the code, you should override this method. But this domain service injects the BlobContainervia interface, as you know, ABP Blob Storing module does not has abstraction that acceptsMime/ContentTypefor saving blobs.So you should create a new YourFileManagerthat inheritsFileManagerand replace it with the current.Inject your blob provider, and override the CreateAsyncmethod, and use your new injected container to storage your blob with mimetype.
- 
    0Thanks, that helps a lot. 
 
                                