mirror of https://github.com/abpframework/abp.git
committed by
GitHub
6 changed files with 144 additions and 0 deletions
@ -0,0 +1,66 @@ |
|||||
|
# BLOB Storing Minio Provider |
||||
|
|
||||
|
BLOB Storing Minio Provider can store BLOBs in [MinIO Object storage](https://min.io/). |
||||
|
|
||||
|
> Read the [BLOB Storing document](Blob-Storing.md) to understand how to use the BLOB storing system. This document only covers how to configure containers to use a Minio BLOB as the storage provider. |
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
Use the ABP CLI to add [Volo.Abp.BlobStoring.Minio](https://www.nuget.org/packages/Volo.Abp.BlobStoring.Minio) NuGet package to your project: |
||||
|
|
||||
|
* Install the [ABP CLI](https://docs.abp.io/en/abp/latest/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.Minio` package. |
||||
|
* Run `abp add-package Volo.Abp.BlobStoring.Minio` command. |
||||
|
|
||||
|
If you want to do it manually, install the [Volo.Abp.BlobStoring.Minio](https://www.nuget.org/packages/Volo.Abp.BlobStoring.Minio) NuGet package to your project and add `[DependsOn(typeof(AbpBlobStoringMinioModule))]` to the [ABP module](Module-Development-Basics.md) class inside your project. |
||||
|
|
||||
|
## Configuration |
||||
|
|
||||
|
Configuration is done in the `ConfigureServices` method of your [module](Module-Development-Basics.md) class, as explained in the [BLOB Storing document](Blob-Storing.md). |
||||
|
|
||||
|
**Example: Configure to use the minio storage provider by default** |
||||
|
|
||||
|
````csharp |
||||
|
Configure<AbpBlobStoringOptions>(options => |
||||
|
{ |
||||
|
options.Containerscontainer.UseMinio(minio => |
||||
|
{ |
||||
|
minio.EndPoint = "your minio endPoint"; |
||||
|
minio.AccessKey = "your minio accessKey"; |
||||
|
minio.SecretKey = "your minio secretKey"; |
||||
|
minio.BucketName = "your minio bucketName"; |
||||
|
}); |
||||
|
}); |
||||
|
```` |
||||
|
|
||||
|
> See the [BLOB Storing document](Blob-Storing.md) to learn how to configure this provider for a specific container. |
||||
|
|
||||
|
### Options |
||||
|
|
||||
|
* **EndPoint** (string): URL to object storage service. Please refer to MinIO Client SDK for .NET: https://docs.min.io/docs/dotnet-client-quickstart-guide.html |
||||
|
* **AccessKey** (string): Access key is the user ID that uniquely identifies your account. |
||||
|
* **SecretKey** (string): Secret key is the password to your account. |
||||
|
* **BucketName** (string): You can specify the bucket name in MinIO. If this is not specified, it uses the name of the BLOB container defined with the `BlogContainerName` attribute (see the [BLOB storing document](Blob-Storing.md)).MinIO is the defacto standard for S3 compatibility, So MinIO has some **rules for naming bucket**. The [following rules](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html) apply for naming MinIO buckets: |
||||
|
* 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. |
||||
|
* **WithSSL** (bool): Default value is `false`,Chain to MinIO Client object to use https instead of http. |
||||
|
* **CreateContainerIfNotExists** (bool): Default value is `false`, If a bucket does not exist in minio, `MinioBlobProvider` will try to create it. |
||||
|
|
||||
|
|
||||
|
## Minio Blob Name Calculator |
||||
|
|
||||
|
Minio 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](Multi-Tenancy.md) is `null` (or multi-tenancy is disabled for the container - see the [BLOB Storing document](Blob-Storing.md) 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 |
||||
|
|
||||
|
* `MinioBlobProvider` is the main service that implements the Minio BLOB storage provider, if you want to override/replace it via [dependency injection](Dependency-Injection.md) (don't replace `IBlobProvider` interface, but replace `MinioBlobProvider` class). |
||||
|
* `IMinioBlobNameCalculator` is used to calculate the full BLOB name (that is explained above). It is implemented by the `DefaultMinioBlobNameCalculator` by default. |
||||
@ -0,0 +1,66 @@ |
|||||
|
# BLOB Storing Minio 提供程序 |
||||
|
|
||||
|
BLOB Storing Minio提供程序帮助你存储对象到 [MinIO Object storage](https://min.io/), |
||||
|
|
||||
|
> 阅读[BLOB存储文档](Blob-Storing.md)了解如何使用BLOB存储系统, 本文档仅介绍如何为容器配置Minio提供程序, |
||||
|
|
||||
|
## 安装 |
||||
|
|
||||
|
使用 ABP CLI 来安装 [Volo.Abp.BlobStoring.Minio](https://www.nuget.org/packages/Volo.Abp.BlobStoring.Minio) NuGet 包到你的项目: |
||||
|
|
||||
|
* 如果你没有安装ABP CLI,请先安装 [ABP CLI](https://docs.abp.io/en/abp/latest/CLI), |
||||
|
* 在要添加 `Volo.Abp.BlobStoring.Minio` 包的 `.csproj` 文件目录打开命令行, |
||||
|
* 执行 `abp add-package Volo.Abp.BlobStoring.Minio` 命令, |
||||
|
|
||||
|
如果你要手动安装, 通过NuGet安装 [Volo.Abp.BlobStoring.Minio](https://www.nuget.org/packages/Volo.Abp.BlobStoring.Minio) 到你的项目,然后添加 `[DependsOn(typeof(AbpBlobStoringMinioModule))]` 特性到你的 [ABP module](Module-Development-Basics.md) 类上, |
||||
|
|
||||
|
## 配置 |
||||
|
|
||||
|
配置在你的[module](Module-Development-Basics.md)类中的`ConfigureServices`方法中完成, |
||||
|
|
||||
|
**例: 配置使用Minio存储** |
||||
|
|
||||
|
````csharp |
||||
|
Configure<AbpBlobStoringOptions>(options => |
||||
|
{ |
||||
|
options.Containerscontainer.UseMinio(minio => |
||||
|
{ |
||||
|
minio.EndPoint = "你的 minio endPoint"; |
||||
|
minio.AccessKey = "你的 minio accessKey"; |
||||
|
minio.SecretKey = "你的 minio secretKey"; |
||||
|
minio.BucketName = "你的 minio bucketName"; |
||||
|
}); |
||||
|
}); |
||||
|
```` |
||||
|
|
||||
|
> 参阅[BLOB存储文档](Blob-Storing.md) 学习如何为指定容器配置提供程序, |
||||
|
|
||||
|
### 选项 |
||||
|
|
||||
|
* **EndPoint** (string): 你的Minio对象存储服务的URL, 查看文档:https://docs.min.io/docs/dotnet-client-quickstart-guide.html |
||||
|
* **AccessKey** (string): Access key是唯一标识你的账户的用户ID, |
||||
|
* **SecretKey** (string): Access key是唯一标识你的账户的用户ID |
||||
|
* **BucketName** (string):你可以指定bucket名称,如果没有指定,将使用 `BlogContainerName` 属性定义的BLOB容器的名称(查阅[BLOB storing document](Blob-Storing.md)),MinIO完全兼容S3标准,所以有一些 **bucket命名规则**,必须符合[规则](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html): |
||||
|
* Bucket名字必须 **3** 到 **63** 字符长度. |
||||
|
* Bucket名字必须是 **小写** 的字母,数字,点号(.), 横杠 (-), |
||||
|
* Bucket名字必须是以数字和字母开头和结尾, |
||||
|
* Bucket名字不能是ip (例如, 192.168.5.4), |
||||
|
* Bucket名字不能以 **xn--** 开头, (2020年2月以后创建), |
||||
|
* Bucket名字必须区块唯一 |
||||
|
* Buckets如果使用Amazon S3加速传输名字不能有点号(.), |
||||
|
* **WithSSL** (bool): 默认 `false`,代表使用HTTPS, |
||||
|
* **CreateContainerIfNotExists** (bool): 默认 `false`,如果不存在bucket, `MinioBlobProvider` 将会创建一个, |
||||
|
|
||||
|
|
||||
|
## Minio BLOB 名称计算器 |
||||
|
|
||||
|
默认情况下BLOB的全名由以下规则确定: |
||||
|
|
||||
|
* 如果当前租户为 `null`(或容器禁用多租户 - 请参阅[BLOB存储文档](Blob-Storing.md) 了解如何禁用容器的多租户),则追加 `host` 字符串, |
||||
|
* 如果当前租户不为 `null`,则追加 `tenants/<tenant-id>` 字符串, |
||||
|
* 追加 BLOB 名称, |
||||
|
|
||||
|
## 其他服务 |
||||
|
|
||||
|
* `MinioBlobProvider` 是实现Minio BLOB存储提供程序的主要服务,如果你想要通过[依赖注入](Dependency-Injection.md)覆盖/替换它(不要替换 `IBlobProvider` 接口,而是替换 `MinioBlobProvider` 类). |
||||
|
* `IMinioBlobNameCalculator` 服务用于计算文件路径. 默认实现是 `DefaultMinioBlobNameCalculator`. 如果你想自定义文件路径计算,可以替换/覆盖它. |
||||
Loading…
Reference in new issue