Z.OSSCore
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Z.OSSCore --version 1.0.2
NuGet\Install-Package Z.OSSCore -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Z.OSSCore" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Z.OSSCore --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Z.OSSCore, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Z.OSSCore as a Cake Addin #addin nuget:?package=Z.OSSCore&version=1.0.2 // Install Z.OSSCore as a Cake Tool #tool nuget:?package=Z.OSSCore&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🎨OSS类库,现已实现ALiyun和Minio正常使用
基于扩展包OnceMi.AspNetCore.OSS修改了一下工厂实现,传入指定类型使用指定的储存
新增了三个方法
-
//获取 public async Task<ObjectOutPut> GetObjectAsync(GetObjectInput input) { //....... } //上传 public async Task<bool> UploadObjectAsync(UploadObjectInput input) { //....... } //删除 public Task<bool> RemoveObjectAsync(OperateObjectInput input) { //....... }
Z.OSSCore
1.0.1
- 加入腾讯云OSS
OSSQCloud
- 加入腾讯云OSS
Z.OSSCore
1.0.0
基础Options实体 以及类型枚举
public enum OSSProvider { /// <summary> /// 无效 /// </summary> Invalid = 0, /// <summary> /// Minio自建对象储存 /// </summary> Minio = 1, /// <summary> /// 阿里云OSS /// </summary> Aliyun = 2, /// <summary> /// 腾讯云OSS /// </summary> QCloud = 3, } public class OSSOptions { /// <summary> /// BucketName /// </summary> public string DefaultBucket { get; set; } /// <summary> /// 枚举,OOS提供商 /// </summary> public OSSProvider Provider { get; set; } //....... }
服务注册
/// <summary> /// 配置默认配置 /// 使用key默认"App:SSOConfig",可以自己配置不同的路径获取 /// </summary> public static IServiceCollection AddOSSService(this IServiceCollection services, string key = "App:SSOConfig", Action<OSSOptions> oSSOptions = null) { } /// <summary> /// 配置默认配置 /// </summary> public static IServiceCollection AddOSSService(this IServiceCollection services, Action<OSSOptions> option) { return services.AddOSSService(oSSOptions: option); }
json配置
"App": { "SSOConfig": { "Enable": false,//是否开启 "Endpoint": "oss-cn-guangzhou.aliyuncs.com",//桶的地址 "AccessKey": "**********", "SecretKey": "***********", "DefaultBucket": "sunblog",//默认Bucket名称 "IsEnableHttps": true,//开启Https "IsEnableCache": true, "Provider": "Minio" }, }
依赖注入使用
public class MinioFileManager : DomainService, IMinioFileManager { private readonly IOSSService<OSSAliyun> _ossService; private readonly OSSOptions _ossOptions; public MinioFileManager(IServiceProvider serviceProvider, IOptions<OSSOptions> minioOptions, IOSSService<OSSAliyun> ossService = null) : base(serviceProvider) { _ossService = ossService; _ossOptions = minioOptions.Value; } 」
其中
OSSAliyun
是不同类型使用的泛型- 现有
OSSAliyun
和OSSMinio
- 现有
安装以上的步骤服务注册以及注入,就可正常使用
- 常用部分方法
-
namespace Z.OSSCore.Interface { public interface IOSSService<T> { /// <summary> /// 检查存储桶是否存在。 /// </summary> /// <param name="bucketName">存储桶名称。</param> /// <returns></returns> Task<bool> BucketExistsAsync(string bucketName); /// <summary> /// 上传文件对象 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<bool> UploadObjectAsync(UploadObjectInput input); /// <summary> /// 返回文件数据 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<ObjectOutPut> GetObjectAsync(GetObjectInput input); /// <summary> /// 删除一个对象。 /// </summary> /// <param name="bucketName">存储桶名称。</param> /// <param name="objectName">存储桶里的对象名称。</param> /// <returns></returns> Task<bool> RemoveObjectAsync(OperateObjectInput input); /// <summary> /// 清除Presigned Object缓存 /// </summary> /// <param name="bucketName"></param> /// <param name="objectName"></param> Task RemovePresignedUrlCache(OperateObjectInput input); } }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Aliyun.OSS.SDK.NetCore (>= 2.13.0)
- Minio (>= 6.0.2)
- Tencent.QCloud.Cos.Sdk (>= 5.4.34)
- Z.Foundation.Core (>= 1.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Z.OSSCore:
Package | Downloads |
---|---|
Z.Fantasy.Core
Core包 |
GitHub repositories
This package is not used by any popular GitHub repositories.