Z.OSSCore 1.0.3

dotnet add package Z.OSSCore --version 1.0.3
NuGet\Install-Package Z.OSSCore -Version 1.0.3
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.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Z.OSSCore --version 1.0.3
#r "nuget: Z.OSSCore, 1.0.3"
#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.3

// Install Z.OSSCore as a Cake Tool
#tool nuget:?package=Z.OSSCore&version=1.0.3

🎨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.OSSCore1.0.1

    • 加入腾讯云OSS OSSQCloud
  • Z.OSSCore1.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是不同类型使用的泛型

        • 现有OSSAliyunOSSMinio
      • 安装以上的步骤服务注册以及注入,就可正常使用

        • 常用部分方法
        • 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 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.

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.

Version Downloads Last updated
1.0.3 92 4/23/2024
1.0.2 82 4/23/2024
1.0.1 115 4/18/2024
1.0.0 93 4/9/2024