OnceMi.AspNetCore.OSS
1.1.0
See the version list below for details.
dotnet add package OnceMi.AspNetCore.OSS --version 1.1.0
NuGet\Install-Package OnceMi.AspNetCore.OSS -Version 1.1.0
<PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.1.0" />
paket add OnceMi.AspNetCore.OSS --version 1.1.0
#r "nuget: OnceMi.AspNetCore.OSS, 1.1.0"
// Install OnceMi.AspNetCore.OSS as a Cake Addin #addin nuget:?package=OnceMi.AspNetCore.OSS&version=1.1.0 // Install OnceMi.AspNetCore.OSS as a Cake Tool #tool nuget:?package=OnceMi.AspNetCore.OSS&version=1.1.0
OnceMi.AspNetCore.OSS
Asp.Net Core 5.0对象储存扩展包,支持Minio自建对象储存、阿里云OSS、腾讯云COS。支持OSS常规操作,比如储存桶创建,删除、对象上传、下载、生成签名URL等。目前仅支持.NET 5,也推荐升级至.NET 5.
OSS Documents
Minio: 点此查看
Aliyun: 点此查看
QCloud: 点此查看
How to use
1、Install OnceMi.AspNetCore.OSS。
CLI中安装:
dotnet add package OnceMi.AspNetCore.OSS
Nuget中安装:
Search and install OnceMi.AspNetCore.OSS
in Nuget manage。
2、Configuration
You need to configure OSSService in your Startup.cs:
//default minio
//添加默认对象储存配置信息
services.AddOSSService(option =>
{
option.Provider = OSSProvider.Minio;
option.Endpoint = "oss.oncemi.com:9000";
option.AccessKey = "Q*************9";
option.SecretKey = "A**************************Q";
option.IsEnableHttps = true;
option.IsEnableCache = true;
});
//aliyun oss
//添加名称为‘aliyunoss’的OSS对象储存配置信息
services.AddOSSService("aliyunoss", option =>
{
option.Provider = OSSProvider.Aliyun;
option.Endpoint = "oss-cn-hangzhou.aliyuncs.com";
option.AccessKey = "L*******************U";
option.SecretKey = "5*******************************T";
option.IsEnableCache = true;
});
//qcloud oss
//从配置文件中加载节点为‘OSSProvider’的配置信息
services.AddOSSService("QCloud", "OSSProvider");
可注入多个OSSService,不同的Service用名称来区分。需要注意的是,腾讯云COS中配置节点Endpoint表示AppId。
配置文件实例:
{
"OSSProvider": {
"Provider": "QCloud", //枚举值支持:Minio/Aliyun/QCloud
"Endpoint": "你的AppId", //腾讯云中表示AppId
"Region": "ap-chengdu", //地域
"AccessKey": "A****************************z",
"SecretKey": "g6I***************la",
"IsEnableCache": true //是否启用缓存,推荐开启
}
}
3、Use
/// <summary>
/// 使用默认的配置文件
/// </summary>
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IOSSService _OSSService;
private readonly string _bucketName = "default-dev";
public HomeController(ILogger<HomeController> logger
, IOSSService OSSService)
{
_logger = logger;
_OSSService = OSSService;
}
}
/// <summary>
/// 获取IOSSServiceFactory,根据名称创建对应的OSS服务
/// </summary>
public class QCloudController : Controller
{
private readonly ILogger<QCloudController> _logger;
private readonly IOSSService _OSSService;
private readonly string _bucketName = "default-dev";
public QCloudController(ILogger<QCloudController> logger
, IOSSServiceFactory ossServiceFactory)
{
_logger = logger;
_OSSService = ossServiceFactory.Create("QCloud");
}
}
列出bucket中的全部文件
public async Task<IActionResult> ListBuckets()
{
try
{
var result = await _OSSService.ListBucketsAsync();
return Json(result);
}
catch (Exception ex)
{
return Content(ex.Message);
}
}
Option Params
名称 | 类型 | 说明 | 案例 | 备注 |
---|---|---|---|---|
Provider | 枚举 | OSS提供者 | Minio | 允许值:Minio,Aliyun, QCloud |
Endpoint | string | 节点 | oss-cn-hangzhou.aliyuncs.com | 在腾讯云OSS中表示AppId |
AccessKey | string | AccessKey | F...............s | |
SecretKey | string | SecretKey | v...............d | |
Region | string | 地域 | ap-chengdu | |
SessionToken | string | token | 仅Minio中使用 | |
IsEnableHttps | bool | 是否启用HTTPS | true | 建议启用 |
IsEnableCache | bool | 是否启用缓存 | true | 启用后将缓存签名URL,以减少请求次数 |
Dependencies
- Aliyun.OSS.SDK.NetCore
- MemoryCache
- Newtonsoft.Json
- Tencent.QCloud.Cos.Sdk
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Aliyun.OSS.SDK.NetCore (>= 2.13.0)
- Crc32.NET (>= 1.2.0)
- Microsoft.AspNetCore.StaticFiles (>= 2.2.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Caching.Memory (>= 6.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.15.0)
- System.Reactive.Linq (>= 5.0.0)
- Tencent.QCloud.Cos.Sdk (>= 5.4.25)
NuGet packages (43)
Showing the top 5 NuGet packages that depend on OnceMi.AspNetCore.OSS:
Package | Downloads |
---|---|
BLT.Common
Package Description |
|
BLT.ServiceFabric
Package Description |
|
Mall3s.ServiceFabric
Package Description |
|
Furion.Extras.Admin.NET
基于Furion框架实现的通用权限管理平台应用层框架。前后端分离,开箱即用。 仓库地址:https://gitee.com/zuohuaijun/Admin.NET,包括前后端完整源码。 |
|
Mall3s.Common
Package Description |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on OnceMi.AspNetCore.OSS:
Repository | Stars |
---|---|
oncemi/OnceMi.Framework
基于.NET 7和Vue 2开发的企业级前后端分离权限管理开发框架(后台管理系统),具有组织管理、角色管理、用户管理、菜单管理、授权管理、计划任务、文件管理等功能。支持国内外多种流行数据库,支持IdentityServer4认证中心。
|
|
leooneone/aibpm.plus
AIBPM是一个开源的工作流引擎。本项目是后端服务,前端请移步aibpm.ui.plus。
|
Version | Downloads | Last updated |
---|---|---|
1.2.0 | 37,312 | 8/9/2023 |
1.1.9 | 84,740 | 10/20/2022 |
1.1.8 | 7,604 | 8/15/2022 |
1.1.7 | 596 | 8/13/2022 |
1.1.6 | 38,860 | 7/10/2022 |
1.1.5 | 6,911 | 5/6/2022 |
1.1.4 | 19,033 | 3/5/2022 |
1.1.3 | 549 | 3/4/2022 |
1.1.1 | 9,266 | 12/26/2021 |
1.1.0 | 71,208 | 12/13/2021 |
1.0.9 | 23,152 | 9/12/2021 |
1.0.8 | 25,417 | 8/7/2021 |
1.0.7 | 432 | 8/7/2021 |
1.0.6 | 1,031 | 8/1/2021 |
1.0.5 | 769 | 7/29/2021 |
1.0.4 | 25,934 | 6/21/2021 |
1.0.3 | 6,515 | 5/7/2021 |
1.0.2 | 833 | 12/30/2020 |
修复错误:MinIO API responded with message=Access denied on the resource: ******/