Open Closed

Getting the FileManagement module to use AWS Blob Storing Provider #960


User avatar
0
dean_ve created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v4.2.1
  • UI type: Blazor
  • DB provider: EF Core (SQL Server)
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace: N/A
  • Steps to reproduce the issue:

I'm trying to get the FIleManagement module to use the AWS Blob provider but it always seems to use the Database provider. This is what I've done.

  1. Created a fresh new ABP 4.2.1 Blazor UI project.
  2. Added the FileManagement Module.
  3. Built solution and was able to add/delete files via the Blazor UI.
  4. Followed the instructions for setting the Blob provider and the AWS Provider.

The FileManagement module still uses the Database provider. I've tried putting the AWS configuration code in the Domain, Application & EntityFramework and HttpApi modules but none seems to work.

Below is the code I have been trying (AWS credentials not shown) from the Domain module.

Thank's in advance for your help!

Dean

<br>

namespace FMTest
{
    [DependsOn(
        typeof(FMTestDomainSharedModule),
        typeof(AbpAuditLoggingDomainModule),
        typeof(AbpBackgroundJobsDomainModule),
        typeof(AbpFeatureManagementDomainModule),
        typeof(AbpIdentityDomainModule),
        typeof(AbpPermissionManagementDomainIdentityModule),
        typeof(AbpIdentityServerDomainModule),
        typeof(AbpPermissionManagementDomainIdentityServerModule),
        typeof(AbpSettingManagementDomainModule),
        typeof(SaasDomainModule),
        typeof(TextTemplateManagementDomainModule),
        typeof(LeptonThemeManagementDomainModule),
        typeof(LanguageManagementDomainModule),
        typeof(VoloAbpCommercialSuiteTemplatesModule),
        typeof(AbpEmailingModule),
        typeof(BlobStoringDatabaseDomainModule)
        )]
    [DependsOn(typeof(FileManagementDomainModule))]
    [DependsOn(typeof(AbpBlobStoringAwsModule))]
    public class FMTestDomainModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            Configure<AbpMultiTenancyOptions>(options =>
            {
                options.IsEnabled = MultiTenancyConsts.IsEnabled;
            });

            Configure<AbpLocalizationOptions>(options =>
            {
                options.Languages.Add(new LanguageInfo("en", "en", "English", "gb"));
                options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe", "tr"));
                options.Languages.Add(new LanguageInfo("sl", "sl", "Slovenščina", "si"));
                options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文", "cn"));
                options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsche", "de"));
                options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
            });

            ConfigureAWSBlobStoring();

#if DEBUG
            context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif
        }

        private void ConfigureAWSBlobStoring()
        {
            Configure<AbpBlobStoringOptions>(options =>
            {
                options.Containers.Configure<FileManagementContainer>(container =>
                {
                    container.UseAws(Aws =>
                    {
                        Aws.AccessKeyId = "your Aws access key id";
                        Aws.SecretAccessKey = "your Aws access key secret";
                        Aws.UseCredentials = false;//"set true to use credentials";
                        Aws.UseTemporaryCredentials = false;// "set true to use temporary credentials";
                        Aws.UseTemporaryFederatedCredentials = false;// "set true to use temporary federated credentials";
                        Aws.ProfileName = "the name of the profile to get credentials from";
                        Aws.ProfilesLocation = "the path to the aws credentials file to look at";
                        Aws.Region = "the system name of the service";
                        Aws.Name = "the name of the federated user";
                        Aws.Policy = "policy";
                        Aws.DurationSeconds = 100000;// "expiration date";
                        Aws.ContainerName = "your Aws container name";
                        Aws.CreateContainerIfNotExists = false;
                    });
                });
            });
        }
    }
}

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

    Hi

    Try remote typeof(BlobStoringDatabaseDomainModule) and Volo.Abp.BlobStoring.Database.* package.

  • User Avatar
    0
    dean_ve created

    Hi,

    Removing typeof(BlobStoringDatabaseDomainModule) and Volo.Abp.BlobStoring.Database.* package from the Domain module had no effect excpet that an exception was thrown when the Download command is used in the Balzor UI.

    Do you have an example of the File Management module using a blob storing provider different from the default database provider? (eg File System, Aws or Azure)

    Dean

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Can I check it remotely? shiwei.liang@volosoft.com

  • User Avatar
    0
    dean_ve created

    Thanks, I got it working on both the file system and AWS.

    I was assuming that there would be no entry in the application database and the file would be just written to the new blob storage. I see that abp writes an entry to the FmFileDescriptors table and puts the actual file data in the configured blob probider.

    Also noted that the configuration code only needs to go in the Domain module.

    I really appreciate your help.

    Dean

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15