BLOB Storing Aws Provider

BLOB Storing Aws Provider can store BLOBs in Amazon Simple Storage Service.

Read the BLOB Storing document to understand how to use the BLOB storing system. This document only covers how to configure containers to use a Aws BLOB as the storage provider.

Installation

Use the ABP CLI to add Volo.Abp.BlobStoring.Aws NuGet package to your project:

  • Install the ABP CLI if you haven’t installed before.
  • Open a command line (terminal) in the directory of the .csproj file you want to add the Volo.Abp.BlobStoring.Aws package.
  • Run abp add-package Volo.Abp.BlobStoring.Aws command.

If you want to do it manually, install the Volo.Abp.BlobStoring.Aws NuGet package to your project and add [DependsOn(typeof(AbpBlobStoringAwsModule))] to the ABP module class inside your project.

Configuration

Configuration is done in the ConfigureServices method of your module class, as explained in the BLOB Storing document.

Example: Configure to use the Aws storage provider by default

  1. Configure<AbpBlobStoringOptions>(options =>
  2. {
  3. options.Containers.ConfigureDefault(container =>
  4. {
  5. container.UseAws(Aws =>
  6. {
  7. Aws.AccessKeyId = "your Aws access key id";
  8. Aws.SecretAccessKey = "your Aws access key secret";
  9. Aws.UseCredentials = "set true to use credentials";
  10. Aws.UseTemporaryCredentials = "set true to use temporary credentials";
  11. Aws.UseTemporaryFederatedCredentials = "set true to use temporary federated credentials";
  12. Aws.ProfileName = "the name of the profile to get credentials from";
  13. Aws.ProfilesLocation = "the path to the aws credentials file to look at";
  14. Aws.Region = "the system name of the service";
  15. Aws.Name = "the name of the federated user";
  16. Aws.Policy = "policy";
  17. Aws.DurationSeconds = "expiration date";
  18. Aws.ContainerName = "your Aws container name";
  19. Aws.CreateContainerIfNotExists = false;
  20. });
  21. });
  22. });

See the BLOB Storing document to learn how to configure this provider for a specific container.

Options

  • AccessKeyId (string): AWS Access Key ID.
  • SecretAccessKey (string): AWS Secret Access Key.
  • UseCredentials (bool): Use credentials to access AWS services,default : false.
  • UseTemporaryCredentials (bool): Use temporary credentials to access AWS services,default : false.
  • UseTemporaryFederatedCredentials (bool): Use federated user temporary credentials to access AWS services, default : false.
  • ProfileName (string): The name of the profile) to get credentials from.
  • ProfilesLocation (string): The path to the aws credentials file to look at.
  • Region (string): The system name of the service.
  • Policy (string): An IAM policy in JSON format that you want to use as an inline session policy.
  • DurationSeconds (int): Validity period(s) of a temporary access certificate,minimum is 900 and the maximum is 3600. note: Using subaccounts operated OSS,if the value is 0.
  • ContainerName (string): You can specify the container name in Aws. If this is not specified, it uses the name of the BLOB container defined with the BlogContainerName attribute (see the BLOB storing document). Please note that Aws has some rules for naming containers. A container name must be a valid DNS name, conforming to the following naming rules:
    • Bucket names must be between 3 and 63 characters long.
    • Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-).
    • Bucket names must begin and end with a letter or number.
    • Bucket names must not be formatted as an IP address (for example, 192.168.5.4).
    • Bucket names can’t begin with xn— (for buckets created after February 2020).
    • Bucket names must be unique within a partition.
    • Buckets used with Amazon S3 Transfer Acceleration can’t have dots (.) in their names. For more information about transfer acceleration, see Amazon S3 Transfer Acceleration.
  • CreateContainerIfNotExists (bool): Default value is false, If a container does not exist in Aws, AwsBlobProvider will try to create it.

Aws Blob Name Calculator

Aws Blob Provider organizes BLOB name and implements some conventions. The full name of a BLOB is determined by the following rules by default:

  • Appends host string if current tenant is null (or multi-tenancy is disabled for the container - see the BLOB Storing document to learn how to disable multi-tenancy for a container).
  • Appends tenants/<tenant-id> string if current tenant is not null.
  • Appends the BLOB name.

Other Services

  • AwsBlobProvider is the main service that implements the Aws BLOB storage provider, if you want to override/replace it via dependency injection (don’t replace IBlobProvider interface, but replace AwsBlobProvider class).
  • IAwsBlobNameCalculator is used to calculate the full BLOB name (that is explained above). It is implemented by the DefaultAwsBlobNameCalculator by default.
  • IAmazonS3ClientFactory is used create OSS client. It is implemented by the DefaultAmazonS3ClientFactory by default. You can override/replace it,if you want customize.