From 5d0d676537922cb1465aa6068aa6db754cbf565f Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 24 Oct 2024 15:14:02 +0800 Subject: [PATCH] feat(oss-management): extract OSS stream processing to the basic module --- aspnet-core/LINGYUN.MicroService.All.sln | 46 ++-- .../LINGYUN.MicroService.SingleProject.sln | 24 +- .../Aliyun/AliyunOssContainer.cs | 35 ++- .../Aliyun/AliyunOssContainerFactory.cs | 14 +- .../OssManagement/AbpOssManagementOptions.cs | 12 +- .../AbpOssManagementOptionsExtensions.cs | 14 ++ .../IOssObjectProcesserContributor.cs | 8 + .../OssManagement/NoneOssObjectProcesser.cs | 13 + .../Abp/OssManagement/OssContainerBase.cs | 68 ++++++ .../OssObjectProcesserContext.cs} | 6 +- .../System/ByteExtensions.cs | 31 +++ .../System/StringArrayArgsExtensions.cs | 31 +++ ...OssManagementFileSystemImageSharpModule.cs | 15 -- ...gementFileSystemImagingImageSharpModule.cs | 12 - .../FileSystem/FileSystemOssContainer.cs | 62 ++--- .../FileSystemOssContainerFactory.cs | 24 +- .../FileSystem/FileSystemOssOptions.cs | 18 -- .../FileSystemOssOptionsExtensions.cs | 14 -- ...FileSystemOssObjectProcesserContributor.cs | 8 - .../NoneFileSystemOssObjectProcesser.cs | 13 - .../FodyWeavers.xml | 0 .../FodyWeavers.xsd | 0 ...NGYUN.Abp.OssManagement.ImageSharp.csproj} | 48 ++-- .../AbpOssManagementImageSharpModule.cs | 15 ++ .../ImageSharpOssObjectProcesser.cs} | 40 ++-- .../README.md | 4 +- .../FodyWeavers.xml | 0 .../FodyWeavers.xsd | 0 ...p.OssManagement.Imaging.ImageSharp.csproj} | 8 +- ...AbpOssManagementImagingImageSharpModule.cs | 11 + .../FodyWeavers.xml | 0 .../FodyWeavers.xsd | 58 ++--- .../LINGYUN.Abp.OssManagement.Imaging.csproj} | 8 +- .../Imaging/AbpImagingProcesserContributor.cs | 16 +- .../Imaging/AbpOssManagementImagingModule.cs} | 8 +- .../OssManagement/Minio/MinioOssContainer.cs | 226 +++++++++--------- .../Minio/MinioOssContainerFactory.cs | 25 +- .../OssManagement/Nexus/NexusOssContainer.cs | 143 +++++------ .../Nexus/NexusOssContainerFactory.cs | 15 +- .../Tencent/TencentOssContainer.cs | 155 ++++++------ .../Tencent/TencentOssContainerFactory.cs | 67 +++--- aspnet-core/modules/oss-management/README.md | 15 +- ...LY.MicroService.Applications.Single.csproj | 4 +- ...rviceApplicationsSingleModule.Configure.cs | 1 + .../MicroServiceApplicationsSingleModule.cs | 9 +- 45 files changed, 754 insertions(+), 590 deletions(-) create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptionsExtensions.cs create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/IOssObjectProcesserContributor.cs create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/NoneOssObjectProcesser.cs create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssContainerBase.cs rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssObjectContext.cs => LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssObjectProcesserContext.cs} (81%) create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/ByteExtensions.cs create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/StringArrayArgsExtensions.cs delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/AbpOssManagementFileSystemImageSharpModule.cs delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LIINGYUN/Abp/OssManagement/FileSystem/Imaging/ImageSharp/AbpOssManagementFileSystemImagingImageSharpModule.cs delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptions.cs delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptionsExtensions.cs delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/IFileSystemOssObjectProcesserContributor.cs delete mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/NoneFileSystemOssObjectProcesser.cs rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.ImageSharp => LINGYUN.Abp.OssManagement.ImageSharp}/FodyWeavers.xml (100%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp => LINGYUN.Abp.OssManagement.ImageSharp}/FodyWeavers.xsd (100%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj => LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN.Abp.OssManagement.ImageSharp.csproj} (67%) create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/AbpOssManagementImageSharpModule.cs rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/ImageSharpFileSystemOssObjectProcesser.cs => LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/ImageSharpOssObjectProcesser.cs} (79%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.ImageSharp => LINGYUN.Abp.OssManagement.ImageSharp}/README.md (61%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp => LINGYUN.Abp.OssManagement.Imaging.ImageSharp}/FodyWeavers.xml (100%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging => LINGYUN.Abp.OssManagement.Imaging.ImageSharp}/FodyWeavers.xsd (100%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj => LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.Imaging.ImageSharp.csproj} (63%) create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN/Abp/OssManagement/Imaging/ImageSharp/AbpOssManagementImagingImageSharpModule.cs rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging => LINGYUN.Abp.OssManagement.Imaging}/FodyWeavers.xml (100%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.ImageSharp => LINGYUN.Abp.OssManagement.Imaging}/FodyWeavers.xsd (97%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj => LINGYUN.Abp.OssManagement.Imaging/LINGYUN.Abp.OssManagement.Imaging.csproj} (66%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem => LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement}/Imaging/AbpImagingProcesserContributor.cs (79%) rename aspnet-core/modules/oss-management/{LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpOssManagementFileSystemImagingModule.cs => LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpOssManagementImagingModule.cs} (57%) diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 373a884f8..bab4db830 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -198,8 +198,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem\LINGYUN.Abp.OssManagement.FileSystem.csproj", "{D5036D3F-1C53-47EE-BA50-AD290AE062D7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj", "{3E5EBCEC-78C9-4A1A-BF04-A216AA6A921F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.SettingManagement", "modules\oss-management\LINGYUN.Abp.OssManagement.SettingManagement\LINGYUN.Abp.OssManagement.SettingManagement.csproj", "{BD74BE00-54E4-4979-8797-E8027695F396}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Features.LimitValidation.Redis.Client", "framework\common\LINGYUN.Abp.Features.LimitValidation.Redis.Client\LINGYUN.Abp.Features.LimitValidation.Redis.Client.csproj", "{48DE251A-3482-4934-BC26-F99D2235AC9F}" @@ -616,10 +614,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cli", "cli", "{59627844-A66 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Cli", "framework\cli\LINGYUN.Abp.Cli\LINGYUN.Abp.Cli.csproj", "{2F49E870-DAE2-4D89-98CA-46BBD91C68E2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem.Imaging", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.Imaging\LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj", "{6C8489F4-68B5-4CBC-8463-010C71C23245}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj", "{5177C729-7666-4A6C-9D54-D7E5DEF0E857}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.Work", "framework\wechat\LINGYUN.Abp.WeChat.Work\LINGYUN.Abp.WeChat.Work.csproj", "{E4CEED06-B8E9-41FA-82BF-5401AE101C4B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.Work.Tests", "tests\LINGYUN.Abp.WeChat.Work.Tests\LINGYUN.Abp.WeChat.Work.Tests.csproj", "{9BDE2F3E-6A95-47AC-9BBC-EC8570F2925A}" @@ -764,9 +758,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.Official EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Minio", "modules\oss-management\LINGYUN.Abp.OssManagement.Minio\LINGYUN.Abp.OssManagement.Minio.csproj", "{EB9F1905-1798-4766-8347-A8D2A9DBFAED}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.Minio.Tests", "tests\LINGYUN.Abp.OssManagement.Minio.Tests\LINGYUN.Abp.OssManagement.Minio.Tests.csproj", "{CCE5C620-E17A-4EB1-A17A-9F90311B197D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Minio.Tests", "tests\LINGYUN.Abp.OssManagement.Minio.Tests\LINGYUN.Abp.OssManagement.Minio.Tests.csproj", "{CCE5C620-E17A-4EB1-A17A-9F90311B197D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Domain.Tests", "tests\LINGYUN.Abp.OssManagement.Domain.Tests\LINGYUN.Abp.OssManagement.Domain.Tests.csproj", "{F2AD691B-71B9-4B86-95BC-E020DA6B1E4A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.ImageSharp\LINGYUN.Abp.OssManagement.ImageSharp.csproj", "{76DDE71D-00BD-4BC8-AEA2-31209E2B7E05}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.Imaging", "modules\oss-management\LINGYUN.Abp.OssManagement.Imaging\LINGYUN.Abp.OssManagement.Imaging.csproj", "{267933BD-BFB8-4906-BA39-DF193B2FD558}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.Domain.Tests", "tests\LINGYUN.Abp.OssManagement.Domain.Tests\LINGYUN.Abp.OssManagement.Domain.Tests.csproj", "{F2AD691B-71B9-4B86-95BC-E020DA6B1E4A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.OssManagement.Imaging.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.Imaging.ImageSharp\LINGYUN.Abp.OssManagement.Imaging.ImageSharp.csproj", "{220D3C8D-B117-4319-A911-1D7F53AFE8DB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1066,10 +1066,6 @@ Global {D5036D3F-1C53-47EE-BA50-AD290AE062D7}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5036D3F-1C53-47EE-BA50-AD290AE062D7}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5036D3F-1C53-47EE-BA50-AD290AE062D7}.Release|Any CPU.Build.0 = Release|Any CPU - {3E5EBCEC-78C9-4A1A-BF04-A216AA6A921F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E5EBCEC-78C9-4A1A-BF04-A216AA6A921F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E5EBCEC-78C9-4A1A-BF04-A216AA6A921F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E5EBCEC-78C9-4A1A-BF04-A216AA6A921F}.Release|Any CPU.Build.0 = Release|Any CPU {BD74BE00-54E4-4979-8797-E8027695F396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BD74BE00-54E4-4979-8797-E8027695F396}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD74BE00-54E4-4979-8797-E8027695F396}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1714,14 +1710,6 @@ Global {2F49E870-DAE2-4D89-98CA-46BBD91C68E2}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F49E870-DAE2-4D89-98CA-46BBD91C68E2}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F49E870-DAE2-4D89-98CA-46BBD91C68E2}.Release|Any CPU.Build.0 = Release|Any CPU - {6C8489F4-68B5-4CBC-8463-010C71C23245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6C8489F4-68B5-4CBC-8463-010C71C23245}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6C8489F4-68B5-4CBC-8463-010C71C23245}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6C8489F4-68B5-4CBC-8463-010C71C23245}.Release|Any CPU.Build.0 = Release|Any CPU - {5177C729-7666-4A6C-9D54-D7E5DEF0E857}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5177C729-7666-4A6C-9D54-D7E5DEF0E857}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5177C729-7666-4A6C-9D54-D7E5DEF0E857}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5177C729-7666-4A6C-9D54-D7E5DEF0E857}.Release|Any CPU.Build.0 = Release|Any CPU {E4CEED06-B8E9-41FA-82BF-5401AE101C4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E4CEED06-B8E9-41FA-82BF-5401AE101C4B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4CEED06-B8E9-41FA-82BF-5401AE101C4B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1970,6 +1958,18 @@ Global {F2AD691B-71B9-4B86-95BC-E020DA6B1E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2AD691B-71B9-4B86-95BC-E020DA6B1E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU {F2AD691B-71B9-4B86-95BC-E020DA6B1E4A}.Release|Any CPU.Build.0 = Release|Any CPU + {76DDE71D-00BD-4BC8-AEA2-31209E2B7E05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76DDE71D-00BD-4BC8-AEA2-31209E2B7E05}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76DDE71D-00BD-4BC8-AEA2-31209E2B7E05}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76DDE71D-00BD-4BC8-AEA2-31209E2B7E05}.Release|Any CPU.Build.0 = Release|Any CPU + {267933BD-BFB8-4906-BA39-DF193B2FD558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {267933BD-BFB8-4906-BA39-DF193B2FD558}.Debug|Any CPU.Build.0 = Debug|Any CPU + {267933BD-BFB8-4906-BA39-DF193B2FD558}.Release|Any CPU.ActiveCfg = Release|Any CPU + {267933BD-BFB8-4906-BA39-DF193B2FD558}.Release|Any CPU.Build.0 = Release|Any CPU + {220D3C8D-B117-4319-A911-1D7F53AFE8DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {220D3C8D-B117-4319-A911-1D7F53AFE8DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {220D3C8D-B117-4319-A911-1D7F53AFE8DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {220D3C8D-B117-4319-A911-1D7F53AFE8DB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2068,7 +2068,6 @@ Global {B86EBB6F-A27F-4277-8265-937951A9DCB0} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} {35B17218-9FB6-439E-AF73-9A1454BC923C} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} {D5036D3F-1C53-47EE-BA50-AD290AE062D7} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} - {3E5EBCEC-78C9-4A1A-BF04-A216AA6A921F} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} {BD74BE00-54E4-4979-8797-E8027695F396} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} {48DE251A-3482-4934-BC26-F99D2235AC9F} = {08BD73E6-72CE-4A8A-896D-2DFFF4D7D2F8} {94B47385-E47F-4FD7-A3A9-A7AA122EFC93} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} @@ -2266,8 +2265,6 @@ Global {1D420BA6-2155-4E0D-AAAF-EECC0330A38C} = {DD1B10ED-73E2-41BE-928A-46501050FE2A} {59627844-A66A-46AC-B882-E8F302D0EC24} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} {2F49E870-DAE2-4D89-98CA-46BBD91C68E2} = {59627844-A66A-46AC-B882-E8F302D0EC24} - {6C8489F4-68B5-4CBC-8463-010C71C23245} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} - {5177C729-7666-4A6C-9D54-D7E5DEF0E857} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} {E4CEED06-B8E9-41FA-82BF-5401AE101C4B} = {DD9BE9E7-F6BF-4869-BCD2-82F5072BDA21} {9BDE2F3E-6A95-47AC-9BBC-EC8570F2925A} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} {B4C8056F-7325-4DB1-9F09-A6F37B052192} = {DD9BE9E7-F6BF-4869-BCD2-82F5072BDA21} @@ -2341,6 +2338,9 @@ Global {EB9F1905-1798-4766-8347-A8D2A9DBFAED} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} {CCE5C620-E17A-4EB1-A17A-9F90311B197D} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} {F2AD691B-71B9-4B86-95BC-E020DA6B1E4A} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} + {76DDE71D-00BD-4BC8-AEA2-31209E2B7E05} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} + {267933BD-BFB8-4906-BA39-DF193B2FD558} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} + {220D3C8D-B117-4319-A911-1D7F53AFE8DB} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/LINGYUN.MicroService.SingleProject.sln b/aspnet-core/LINGYUN.MicroService.SingleProject.sln index d184946ab..46a7258a3 100644 --- a/aspnet-core/LINGYUN.MicroService.SingleProject.sln +++ b/aspnet-core/LINGYUN.MicroService.SingleProject.sln @@ -228,6 +228,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TaskManagement.HttpApi", "modules\task-management\LINGYUN.Abp.TaskManagement.HttpApi\LINGYUN.Abp.TaskManagement.HttpApi.csproj", "{3BA4B7EC-65E1-4BCE-8533-6FB2FBA7DFCA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "oss-management", "oss-management", "{3AD66E47-B667-40D1-AE61-F5EC186241F7}" + ProjectSection(SolutionItems) = preProject + modules\oss-management\README.md = modules\oss-management\README.md + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Domain.Shared", "modules\oss-management\LINGYUN.Abp.OssManagement.Domain.Shared\LINGYUN.Abp.OssManagement.Domain.Shared.csproj", "{AD3E63A3-3422-4A1A-AC89-B20786A5323E}" EndProject @@ -235,8 +238,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem\LINGYUN.Abp.OssManagement.FileSystem.csproj", "{90F837CB-72DF-40B7-8DA0-6E568ECEEF0A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.FileSystem.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp\LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj", "{72410751-25FF-4B13-9D80-97F021716662}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.HttpApi", "modules\oss-management\LINGYUN.Abp.OssManagement.HttpApi\LINGYUN.Abp.OssManagement.HttpApi.csproj", "{34C9609F-556B-44D7-B3DE-5637FEB0BFEC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Application.Contracts", "modules\oss-management\LINGYUN.Abp.OssManagement.Application.Contracts\LINGYUN.Abp.OssManagement.Application.Contracts.csproj", "{A69E6742-39A6-4C0D-A098-E16A653331AC}" @@ -599,6 +600,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Exporter.Magico EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Minio", "modules\oss-management\LINGYUN.Abp.OssManagement.Minio\LINGYUN.Abp.OssManagement.Minio.csproj", "{9AE3E97E-8846-4315-9546-FF97E97FD49F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Imaging", "modules\oss-management\LINGYUN.Abp.OssManagement.Imaging\LINGYUN.Abp.OssManagement.Imaging.csproj", "{BC7A8662-4313-4F1D-B267-9B1B69444CD3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Imaging.ImageSharp", "modules\oss-management\LINGYUN.Abp.OssManagement.Imaging.ImageSharp\LINGYUN.Abp.OssManagement.Imaging.ImageSharp.csproj", "{5325AA6E-FB76-46D2-B1C8-BAAAE15E42F3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -977,10 +982,6 @@ Global {90F837CB-72DF-40B7-8DA0-6E568ECEEF0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {90F837CB-72DF-40B7-8DA0-6E568ECEEF0A}.Release|Any CPU.ActiveCfg = Release|Any CPU {90F837CB-72DF-40B7-8DA0-6E568ECEEF0A}.Release|Any CPU.Build.0 = Release|Any CPU - {72410751-25FF-4B13-9D80-97F021716662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72410751-25FF-4B13-9D80-97F021716662}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72410751-25FF-4B13-9D80-97F021716662}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72410751-25FF-4B13-9D80-97F021716662}.Release|Any CPU.Build.0 = Release|Any CPU {34C9609F-556B-44D7-B3DE-5637FEB0BFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {34C9609F-556B-44D7-B3DE-5637FEB0BFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {34C9609F-556B-44D7-B3DE-5637FEB0BFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1581,6 +1582,14 @@ Global {9AE3E97E-8846-4315-9546-FF97E97FD49F}.Debug|Any CPU.Build.0 = Debug|Any CPU {9AE3E97E-8846-4315-9546-FF97E97FD49F}.Release|Any CPU.ActiveCfg = Release|Any CPU {9AE3E97E-8846-4315-9546-FF97E97FD49F}.Release|Any CPU.Build.0 = Release|Any CPU + {BC7A8662-4313-4F1D-B267-9B1B69444CD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC7A8662-4313-4F1D-B267-9B1B69444CD3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC7A8662-4313-4F1D-B267-9B1B69444CD3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC7A8662-4313-4F1D-B267-9B1B69444CD3}.Release|Any CPU.Build.0 = Release|Any CPU + {5325AA6E-FB76-46D2-B1C8-BAAAE15E42F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5325AA6E-FB76-46D2-B1C8-BAAAE15E42F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5325AA6E-FB76-46D2-B1C8-BAAAE15E42F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5325AA6E-FB76-46D2-B1C8-BAAAE15E42F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1697,7 +1706,6 @@ Global {AD3E63A3-3422-4A1A-AC89-B20786A5323E} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} {CA2975D9-5477-4281-8D84-F0909F22DFF3} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} {90F837CB-72DF-40B7-8DA0-6E568ECEEF0A} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} - {72410751-25FF-4B13-9D80-97F021716662} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} {34C9609F-556B-44D7-B3DE-5637FEB0BFEC} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} {A69E6742-39A6-4C0D-A098-E16A653331AC} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} {6AC4C18F-2BB5-47F9-99F5-5585E1D22111} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} @@ -1873,6 +1881,8 @@ Global {CBC64BD6-297B-48F6-A3BA-0DBB4B0F5A69} = {4A2CF141-F32D-45A0-8665-B3705667A6D2} {319428B9-CE7F-4027-92FA-6311C4CE95FB} = {4A2CF141-F32D-45A0-8665-B3705667A6D2} {9AE3E97E-8846-4315-9546-FF97E97FD49F} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} + {BC7A8662-4313-4F1D-B267-9B1B69444CD3} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} + {5325AA6E-FB76-46D2-B1C8-BAAAE15E42F3} = {3AD66E47-B667-40D1-AE61-F5EC186241F7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {711A43C0-A2F8-4E5C-9B9F-F2551E4B3FF1} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs index ae96376ca..59293f610 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs @@ -1,5 +1,7 @@ using Aliyun.OSS; using LINGYUN.Abp.BlobStoring.Aliyun; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.IO; @@ -13,18 +15,21 @@ namespace LINGYUN.Abp.OssManagement.Aliyun; /// /// Oss容器的阿里云实现 /// -internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor +internal class AliyunOssContainer : OssContainerBase, IOssObjectExpireor { protected ICurrentTenant CurrentTenant { get; } protected IOssClientFactory OssClientFactory { get; } public AliyunOssContainer( ICurrentTenant currentTenant, - IOssClientFactory ossClientFactory) + IOssClientFactory ossClientFactory, + IServiceScopeFactory serviceScopeFactory, + IOptions options) + : base(options, serviceScopeFactory) { CurrentTenant = currentTenant; OssClientFactory = ossClientFactory; } - public async virtual Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) + public async override Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -34,7 +39,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor ossClient.DeleteObjects(aliyunRequest); } - public async virtual Task CreateAsync(string name) + public async override Task CreateAsync(string name) { var ossClient = await CreateClientAsync(); @@ -57,7 +62,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor }); } - public async virtual Task CreateObjectAsync(CreateOssObjectRequest request) + public async override Task CreateObjectAsync(CreateOssObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -125,7 +130,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor return ossObject; } - public async virtual Task DeleteAsync(string name) + protected async override Task DeleteBucketAsync(string name) { // 阿里云oss在控制台设置即可,无需改变 var ossClient = await CreateClientAsync(); @@ -166,7 +171,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor } } - public async virtual Task DeleteObjectAsync(GetOssObjectRequest request) + public async override Task DeleteObjectAsync(GetOssObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -190,14 +195,14 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor } } - public async virtual Task ExistsAsync(string name) + public async override Task ExistsAsync(string name) { var ossClient = await CreateClientAsync(); return BucketExists(ossClient, name); } - public async virtual Task GetAsync(string name) + public async override Task GetAsync(string name) { var ossClient = await CreateClientAsync(); if (!BucketExists(ossClient, name)) @@ -219,7 +224,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor }); } - public async virtual Task GetObjectAsync(GetOssObjectRequest request) + protected async override Task GetOssObjectAsync(GetOssObjectRequest request) { var ossClient = await CreateClientAsync(); if (!BucketExists(ossClient, request.Bucket)) @@ -264,7 +269,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor return ossObject; } - public async virtual Task GetListAsync(GetOssContainersRequest request) + public async override Task GetListAsync(GetOssContainersRequest request) { var ossClient = await CreateClientAsync(); @@ -296,7 +301,7 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor .ToList()); } - public async virtual Task GetObjectsAsync(GetOssObjectsRequest request) + public async override Task GetObjectsAsync(GetOssObjectsRequest request) { var ossClient = await CreateClientAsync(); @@ -400,4 +405,10 @@ internal class AliyunOssContainer : IOssContainer, IOssObjectExpireor { return await OssClientFactory.CreateAsync(); } + + protected override bool ShouldProcessObject(OssObject ossObject) + { + // 阿里云自行处理 + return false; + } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainerFactory.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainerFactory.cs index 3b43ed1ee..bae8f5af7 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainerFactory.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainerFactory.cs @@ -1,4 +1,6 @@ using LINGYUN.Abp.BlobStoring.Aliyun; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.OssManagement.Aliyun; @@ -7,11 +9,17 @@ public class AliyunOssContainerFactory : IOssContainerFactory { protected ICurrentTenant CurrentTenant { get; } protected IOssClientFactory OssClientFactory { get; } + protected IServiceScopeFactory ServiceScopeFactory { get; } + protected IOptions Options { get; } public AliyunOssContainerFactory( ICurrentTenant currentTenant, - IOssClientFactory ossClientFactory) + IOssClientFactory ossClientFactory, + IServiceScopeFactory serviceScopeFactory, + IOptions options) { + Options = options; + ServiceScopeFactory = serviceScopeFactory; CurrentTenant = currentTenant; OssClientFactory = ossClientFactory; } @@ -20,6 +28,8 @@ public class AliyunOssContainerFactory : IOssContainerFactory { return new AliyunOssContainer( CurrentTenant, - OssClientFactory); + OssClientFactory, + ServiceScopeFactory, + Options); } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptions.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptions.cs index 9978a8d4e..b57a49104 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptions.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptions.cs @@ -1,4 +1,5 @@ -using System; +using JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Linq; using Volo.Abp; @@ -38,6 +39,11 @@ public class AbpOssManagementOptions /// default: 30 minutes /// public TimeSpan MinimumTempLifeSpan { get; set; } + /// + /// 文件流处理器 + /// + [NotNull] + public List Processers { get; } public AbpOssManagementOptions() { @@ -56,6 +62,10 @@ public class AbpOssManagementOptions // 缓存 "temp" }; + Processers = new List + { + new NoneOssObjectProcesser() + }; IsCleanupEnabled = true; CleanupPeriod = 3_600_000; diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptionsExtensions.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptionsExtensions.cs new file mode 100644 index 000000000..a54577640 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/AbpOssManagementOptionsExtensions.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace LINGYUN.Abp.OssManagement; + +public static class AbpOssManagementOptionsExtensions +{ + public static void AddProcesser( + this AbpOssManagementOptions options, + TProcesserContributor contributor) + where TProcesserContributor : IOssObjectProcesserContributor + { + options.Processers.InsertBefore((x) => x is NoneOssObjectProcesser, contributor); + } +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/IOssObjectProcesserContributor.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/IOssObjectProcesserContributor.cs new file mode 100644 index 000000000..dda063c33 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/IOssObjectProcesserContributor.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.OssManagement; + +public interface IOssObjectProcesserContributor +{ + Task ProcessAsync(OssObjectProcesserContext context); +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/NoneOssObjectProcesser.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/NoneOssObjectProcesser.cs new file mode 100644 index 000000000..ba3869de1 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/NoneOssObjectProcesser.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.OssManagement; + +public class NoneOssObjectProcesser : IOssObjectProcesserContributor +{ + public Task ProcessAsync(OssObjectProcesserContext context) + { + context.SetContent(context.OssObject.Content); + + return Task.CompletedTask; + } +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssContainerBase.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssContainerBase.cs new file mode 100644 index 000000000..ecd8670b3 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssContainerBase.cs @@ -0,0 +1,68 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using System; +using System.Threading.Tasks; +using Volo.Abp; + +namespace LINGYUN.Abp.OssManagement; +public abstract class OssContainerBase : IOssContainer +{ + protected AbpOssManagementOptions Options { get; } + protected IServiceScopeFactory ServiceScopeFactory { get; } + + protected OssContainerBase( + IOptions options, + IServiceScopeFactory serviceScopeFactory) + { + Options = options.Value; + ServiceScopeFactory = serviceScopeFactory; + } + + public async virtual Task GetObjectAsync(GetOssObjectRequest request) + { + var ossObject = await GetOssObjectAsync(request); + + if (ShouldProcessObject(ossObject) && !request.Process.IsNullOrWhiteSpace()) + { + using var serviceScope = ServiceScopeFactory.CreateScope(); + var context = new OssObjectProcesserContext(request.Process, ossObject, serviceScope.ServiceProvider); + foreach (var processer in Options.Processers) + { + await processer.ProcessAsync(context); + + if (context.Handled) + { + ossObject.SetContent(context.Content); + break; + } + } + } + + return ossObject; + } + + public async virtual Task DeleteAsync(string name) + { + if (Options.CheckStaticBucket(name)) + { + throw new BusinessException(code: OssManagementErrorCodes.ContainerDeleteWithStatic); + } + + await DeleteBucketAsync(name); + } + + public abstract Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request); + public abstract Task CreateAsync(string name); + public abstract Task CreateObjectAsync(CreateOssObjectRequest request); + public abstract Task DeleteObjectAsync(GetOssObjectRequest request); + public abstract Task ExistsAsync(string name); + public abstract Task GetAsync(string name); + public abstract Task GetListAsync(GetOssContainersRequest request); + public abstract Task GetObjectsAsync(GetOssObjectsRequest request); + protected abstract Task DeleteBucketAsync(string name); + protected abstract Task GetOssObjectAsync(GetOssObjectRequest request); + protected virtual bool ShouldProcessObject(OssObject ossObject) + { + return true; + } +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssObjectContext.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssObjectProcesserContext.cs similarity index 81% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssObjectContext.cs rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssObjectProcesserContext.cs index 5185a15fd..18626186f 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssObjectContext.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/LINGYUN/Abp/OssManagement/OssObjectProcesserContext.cs @@ -2,9 +2,9 @@ using System.IO; using Volo.Abp.DependencyInjection; -namespace LINGYUN.Abp.OssManagement.FileSystem; +namespace LINGYUN.Abp.OssManagement; -public class FileSystemOssObjectContext : IServiceProviderAccessor +public class OssObjectProcesserContext : IServiceProviderAccessor { public string Process { get; } public OssObject OssObject { get; } @@ -12,7 +12,7 @@ public class FileSystemOssObjectContext : IServiceProviderAccessor public Stream Content { get; private set; } public IServiceProvider ServiceProvider { get; } - public FileSystemOssObjectContext( + public OssObjectProcesserContext( string process, OssObject ossObject, IServiceProvider serviceProvider) diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/ByteExtensions.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/ByteExtensions.cs new file mode 100644 index 000000000..ccf86b05c --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/ByteExtensions.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace System; +public static class ByteExtensions +{ + private readonly static string[] ImageTypes = new string[] + { + "6677",// bmp + "7173",// gif + "13780",// png + "255216"// jpg + }; + + public static bool IsImage(this byte[] fileBytes) + { + if (fileBytes.IsNullOrEmpty()) + { + return false; + } + + string fileclass = ""; + for (int i = 0; i < 2; i++) + { + fileclass += fileBytes[i].ToString(); + } + + return ImageTypes.Any(type => type.Equals(fileclass)); + } +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/StringArrayArgsExtensions.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/StringArrayArgsExtensions.cs new file mode 100644 index 000000000..fdad716e9 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain/System/StringArrayArgsExtensions.cs @@ -0,0 +1,31 @@ +using System.Linq; + +namespace System; +public static class StringArrayArgsExtensions +{ + public static string GetStringPrarm(this string[] args, string key) + { + if (!args.Any()) + { + return null; + } + + return args + .Where(arg => arg.StartsWith(key)) + .Select(arg => arg.Substring(key.Length)) + .FirstOrDefault(); + } + + public static string GetInt32Prarm(this string[] args, string key) + { + if (!args.Any()) + { + return null; + } + + return args + .Where(arg => arg.StartsWith(key)) + .Select(arg => arg.Substring(key.Length)) + .FirstOrDefault(arg => int.TryParse(arg, out _)); + } +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/AbpOssManagementFileSystemImageSharpModule.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/AbpOssManagementFileSystemImageSharpModule.cs deleted file mode 100644 index 440aacc37..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/AbpOssManagementFileSystemImageSharpModule.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Volo.Abp.Modularity; - -namespace LINGYUN.Abp.OssManagement.FileSystem.ImageSharp; - -[DependsOn(typeof(AbpOssManagementFileSystemModule))] -public class AbpOssManagementFileSystemImageSharpModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.AddProcesser(new ImageSharpProcesserContributor()); - }); - } -} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LIINGYUN/Abp/OssManagement/FileSystem/Imaging/ImageSharp/AbpOssManagementFileSystemImagingImageSharpModule.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LIINGYUN/Abp/OssManagement/FileSystem/Imaging/ImageSharp/AbpOssManagementFileSystemImagingImageSharpModule.cs deleted file mode 100644 index 6378db3f6..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LIINGYUN/Abp/OssManagement/FileSystem/Imaging/ImageSharp/AbpOssManagementFileSystemImagingImageSharpModule.cs +++ /dev/null @@ -1,12 +0,0 @@ -using LINGYUN.Abp.OssManagement.FileSystem.Imaging; -using Volo.Abp.Imaging; -using Volo.Abp.Modularity; - -namespace LIINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp; - -[DependsOn( - typeof(AbpImagingImageSharpModule), - typeof(AbpOssManagementFileSystemImagingModule))] -public class AbpOssManagementFileSystemImagingImageSharpModule : AbpModule -{ -} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainer.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainer.cs index d44ef2f19..c27003be8 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainer.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainer.cs @@ -17,35 +17,29 @@ namespace LINGYUN.Abp.OssManagement.FileSystem; /// /// Oss容器的本地文件系统实现 /// -internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor +internal class FileSystemOssContainer : OssContainerBase, IOssObjectExpireor { protected ICurrentTenant CurrentTenant { get; } protected IHostEnvironment Environment { get; } protected IBlobFilePathCalculator FilePathCalculator { get; } protected IBlobContainerConfigurationProvider ConfigurationProvider { get; } - protected IServiceProvider ServiceProvider { get; } - protected FileSystemOssOptions Options { get; } - protected AbpOssManagementOptions OssOptions { get; } public FileSystemOssContainer( ICurrentTenant currentTenant, IHostEnvironment environment, - IServiceProvider serviceProvider, + IServiceScopeFactory serviceScopeFactory, IBlobFilePathCalculator blobFilePathCalculator, IBlobContainerConfigurationProvider configurationProvider, - IOptions options, IOptions ossOptions) + : base(ossOptions, serviceScopeFactory) { CurrentTenant = currentTenant; Environment = environment; - ServiceProvider = serviceProvider; FilePathCalculator = blobFilePathCalculator; ConfigurationProvider = configurationProvider; - Options = options.Value; - OssOptions = ossOptions.Value; } - public virtual Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) + public override Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) { var objectPath = !request.Path.IsNullOrWhiteSpace() ? request.Path.EnsureEndsWith('/') @@ -72,7 +66,7 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return Task.CompletedTask; } - public virtual Task CreateAsync(string name) + public override Task CreateAsync(string name) { var filePath = CalculateFilePath(name); ThrowOfPathHasTooLong(filePath); @@ -128,7 +122,7 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return Task.CompletedTask; } - public async virtual Task CreateObjectAsync(CreateOssObjectRequest request) + public async override Task CreateObjectAsync(CreateOssObjectRequest request) { var objectPath = !request.Path.IsNullOrWhiteSpace() ? request.Path.EnsureEndsWith('/') @@ -213,10 +207,8 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor } } - public virtual Task DeleteAsync(string name) + protected override Task DeleteBucketAsync(string name) { - CheckStaticBucket(name); - var filePath = CalculateFilePath(name); if (!Directory.Exists(filePath)) { @@ -233,7 +225,7 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return Task.CompletedTask; } - public virtual Task DeleteObjectAsync(GetOssObjectRequest request) + public override Task DeleteObjectAsync(GetOssObjectRequest request) { var objectName = request.Path.IsNullOrWhiteSpace() ? request.Object @@ -255,14 +247,14 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return Task.CompletedTask; } - public virtual Task ExistsAsync(string name) + public override Task ExistsAsync(string name) { var filePath = CalculateFilePath(name); return Task.FromResult(Directory.Exists(filePath)); } - public virtual Task GetAsync(string name) + public override Task GetAsync(string name) { var filePath = CalculateFilePath(name); if (!Directory.Exists(filePath)) @@ -285,7 +277,7 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return Task.FromResult(container); } - public async virtual Task GetObjectAsync(GetOssObjectRequest request) + protected override Task GetOssObjectAsync(GetOssObjectRequest request) { var objectPath = !request.Path.IsNullOrWhiteSpace() ? request.Path.EnsureEndsWith('/') @@ -321,7 +313,7 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor { FullName = directoryInfo.FullName.Replace(Environment.ContentRootPath, "") }; - return ossObject; + return Task.FromResult(ossObject); } else { @@ -345,27 +337,11 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor ossObject.SetContent(fileStream); - if (!request.Process.IsNullOrWhiteSpace()) - { - using var serviceScope = ServiceProvider.CreateScope(); - var context = new FileSystemOssObjectContext(request.Process, ossObject, serviceScope.ServiceProvider); - foreach (var processer in Options.Processers) - { - await processer.ProcessAsync(context); - - if (context.Handled) - { - ossObject.SetContent(context.Content); - break; - } - } - } - - return ossObject; + return Task.FromResult(ossObject); } } - public virtual Task GetListAsync(GetOssContainersRequest request) + public override Task GetListAsync(GetOssContainersRequest request) { // 不传递Bucket 检索根目录的Bucket var filePath = CalculateFilePath(null); @@ -412,7 +388,7 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return Task.FromResult(response); } - public virtual Task GetObjectsAsync(GetOssObjectsRequest request) + public override Task GetObjectsAsync(GetOssObjectsRequest request) { // 先定位检索的目录 var filePath = CalculateFilePath(request.BucketName, request.Prefix); @@ -572,14 +548,6 @@ internal class FileSystemOssContainer : IOssContainer, IOssObjectExpireor return blobPath; } - protected virtual void CheckStaticBucket(string bucket) - { - if (OssOptions.CheckStaticBucket(bucket)) - { - throw new BusinessException(code: OssManagementErrorCodes.ContainerDeleteWithStatic); - } - } - private void ThrowOfPathHasTooLong(string path) { // Windows 133 260 diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainerFactory.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainerFactory.cs index 60942b9ae..de3522f53 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainerFactory.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssContainerFactory.cs @@ -1,6 +1,6 @@ -using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -using System; using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.FileSystem; using Volo.Abp.MultiTenancy; @@ -11,28 +11,25 @@ public class FileSystemOssContainerFactory : IOssContainerFactory { protected ICurrentTenant CurrentTenant { get; } protected IHostEnvironment Environment { get; } - protected IServiceProvider ServiceProvider { get; } + protected IServiceScopeFactory ServiceScopeFactory { get; } protected IBlobFilePathCalculator FilePathCalculator { get; } protected IBlobContainerConfigurationProvider ConfigurationProvider { get; } - protected IOptions Options { get; } - protected IOptions OssOptions { get; } + protected IOptions Options { get; } public FileSystemOssContainerFactory( ICurrentTenant currentTenant, IHostEnvironment environment, - IServiceProvider serviceProvider, + IServiceScopeFactory serviceScopeFactory, IBlobFilePathCalculator blobFilePathCalculator, IBlobContainerConfigurationProvider configurationProvider, - IOptions options, - IOptions ossOptions) + IOptions options) { + Options = options; Environment = environment; CurrentTenant = currentTenant; - ServiceProvider = serviceProvider; + ServiceScopeFactory = serviceScopeFactory; FilePathCalculator = blobFilePathCalculator; ConfigurationProvider = configurationProvider; - Options = options; - OssOptions = ossOptions; } public IOssContainer Create() @@ -40,10 +37,9 @@ public class FileSystemOssContainerFactory : IOssContainerFactory return new FileSystemOssContainer( CurrentTenant, Environment, - ServiceProvider, + ServiceScopeFactory, FilePathCalculator, ConfigurationProvider, - Options, - OssOptions); + Options); } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptions.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptions.cs deleted file mode 100644 index b4f8dbb15..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using System.Collections.Generic; - -namespace LINGYUN.Abp.OssManagement.FileSystem; - -public class FileSystemOssOptions -{ - [NotNull] - public List Processers { get; } - - public FileSystemOssOptions() - { - Processers = new List - { - new NoneFileSystemOssObjectProcesser() - }; - } -} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptionsExtensions.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptionsExtensions.cs deleted file mode 100644 index d88066af7..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/FileSystemOssOptionsExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.OssManagement.FileSystem; - -public static class FileSystemOssOptionsExtensions -{ - public static void AddProcesser( - this FileSystemOssOptions options, - TProcesserContributor contributor) - where TProcesserContributor : IFileSystemOssObjectProcesserContributor - { - options.Processers.InsertBefore((x) => x is NoneFileSystemOssObjectProcesser, contributor); - } -} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/IFileSystemOssObjectProcesserContributor.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/IFileSystemOssObjectProcesserContributor.cs deleted file mode 100644 index 73ba2b716..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/IFileSystemOssObjectProcesserContributor.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Threading.Tasks; - -namespace LINGYUN.Abp.OssManagement.FileSystem; - -public interface IFileSystemOssObjectProcesserContributor -{ - Task ProcessAsync(FileSystemOssObjectContext context); -} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/NoneFileSystemOssObjectProcesser.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/NoneFileSystemOssObjectProcesser.cs deleted file mode 100644 index b1465a615..000000000 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem/LINGYUN/Abp/OssManagement/FileSystem/NoneFileSystemOssObjectProcesser.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; - -namespace LINGYUN.Abp.OssManagement.FileSystem; - -public class NoneFileSystemOssObjectProcesser : IFileSystemOssObjectProcesserContributor -{ - public Task ProcessAsync(FileSystemOssObjectContext context) - { - context.SetContent(context.OssObject.Content); - - return Task.CompletedTask; - } -} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/FodyWeavers.xml b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/FodyWeavers.xml similarity index 100% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/FodyWeavers.xml rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/FodyWeavers.xml diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/FodyWeavers.xsd b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/FodyWeavers.xsd similarity index 100% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/FodyWeavers.xsd rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/FodyWeavers.xsd diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN.Abp.OssManagement.ImageSharp.csproj similarity index 67% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN.Abp.OssManagement.ImageSharp.csproj index 641f0dbd1..f53e5a7c6 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN.Abp.OssManagement.ImageSharp.csproj @@ -1,24 +1,24 @@ - - - - - - - net8.0 - LINGYUN.Abp.OssManagement.FileSystem.ImageSharp - LINGYUN.Abp.OssManagement.FileSystem.ImageSharp - false - false - false - - - - - - - - - - - - + + + + + + + net8.0 + LINGYUN.Abp.OssManagement.ImageSharp + LINGYUN.Abp.OssManagement.ImageSharp + false + false + false + + + + + + + + + + + + diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/AbpOssManagementImageSharpModule.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/AbpOssManagementImageSharpModule.cs new file mode 100644 index 000000000..a0663ab17 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/AbpOssManagementImageSharpModule.cs @@ -0,0 +1,15 @@ +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.OssManagement.ImageSharp; + +[DependsOn(typeof(AbpOssManagementDomainModule))] +public class AbpOssManagementImageSharpModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.AddProcesser(new ImageSharpOssObjectProcesser()); + }); + } +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/ImageSharpFileSystemOssObjectProcesser.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/ImageSharpOssObjectProcesser.cs similarity index 79% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/ImageSharpFileSystemOssObjectProcesser.cs rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/ImageSharpOssObjectProcesser.cs index 6c90f53e3..dbb3bfc55 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/LINGYUN/Abp/OssManagement/FileSystem/ImageSharp/ImageSharpFileSystemOssObjectProcesser.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/LINGYUN/Abp/OssManagement/ImageSharp/ImageSharpOssObjectProcesser.cs @@ -1,34 +1,28 @@ -using SixLabors.Fonts; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Advanced; -using SixLabors.ImageSharp.Drawing.Processing; -using SixLabors.ImageSharp.Formats; +using SixLabors.ImageSharp; using SixLabors.ImageSharp.Processing; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading.Tasks; -namespace LINGYUN.Abp.OssManagement.FileSystem.ImageSharp; +namespace LINGYUN.Abp.OssManagement.ImageSharp; -public class ImageSharpProcesserContributor : IFileSystemOssObjectProcesserContributor +public class ImageSharpOssObjectProcesser : IOssObjectProcesserContributor { - public async virtual Task ProcessAsync(FileSystemOssObjectContext context) + public async virtual Task ProcessAsync(OssObjectProcesserContext context) { - var copyStream = context.OssObject.Content; - var bytes = await copyStream.GetAllBytesAsync(); - - if (bytes.IsImage()) - { - var args = context.Process.Split(','); - if (DrawGraphics(bytes, args, out var content)) - { - context.SetContent(content); - - // 释放原图形流数据 - await copyStream.DisposeAsync(); - } + var copyStream = context.OssObject.Content; + var bytes = await copyStream.GetAllBytesAsync(); + + if (bytes.IsImage()) + { + var args = context.Process.Split(','); + if (DrawGraphics(bytes, args, out var content)) + { + context.SetContent(content); + + // 释放原图形流数据 + await copyStream.DisposeAsync(); + } } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/README.md b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/README.md similarity index 61% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/README.md rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/README.md index c9af0aece..0ef3abd8b 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/README.md +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.ImageSharp/README.md @@ -1,6 +1,6 @@ -# LINGYUN.Abp.OssManagement.FileSystem.ImageSharp +# LINGYUN.Abp.OssManagement.ImageSharp -本地文件系统oss对象ImageSharp图形处理接口 +oss对象ImageSharp图形处理接口 ## 配置使用 diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/FodyWeavers.xml b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/FodyWeavers.xml similarity index 100% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/FodyWeavers.xml rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/FodyWeavers.xml diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/FodyWeavers.xsd b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/FodyWeavers.xsd similarity index 100% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/FodyWeavers.xsd rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/FodyWeavers.xsd diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.Imaging.ImageSharp.csproj similarity index 63% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.Imaging.ImageSharp.csproj index a22ac4846..bf505dcbd 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN.Abp.OssManagement.Imaging.ImageSharp.csproj @@ -1,12 +1,12 @@ - + net8.0 - LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp - LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp + LINGYUN.Abp.OssManagement.Imaging.ImageSharp + LINGYUN.Abp.OssManagement.Imaging.ImageSharp false false false @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN/Abp/OssManagement/Imaging/ImageSharp/AbpOssManagementImagingImageSharpModule.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN/Abp/OssManagement/Imaging/ImageSharp/AbpOssManagementImagingImageSharpModule.cs new file mode 100644 index 000000000..301c6eb3a --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging.ImageSharp/LINGYUN/Abp/OssManagement/Imaging/ImageSharp/AbpOssManagementImagingImageSharpModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Imaging; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.OssManagement.Imaging.ImageSharp; + +[DependsOn( + typeof(AbpImagingImageSharpModule), + typeof(AbpOssManagementImagingModule))] +public class AbpOssManagementImagingImageSharpModule : AbpModule +{ +} diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/FodyWeavers.xml b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/FodyWeavers.xml similarity index 100% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/FodyWeavers.xml rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/FodyWeavers.xml diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/FodyWeavers.xsd b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/FodyWeavers.xsd similarity index 97% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/FodyWeavers.xsd rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/FodyWeavers.xsd index 11da52550..3f3946e28 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.ImageSharp/FodyWeavers.xsd +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/FodyWeavers.xsd @@ -1,30 +1,30 @@ - - - - - - - - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + \ No newline at end of file diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN.Abp.OssManagement.Imaging.csproj similarity index 66% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN.Abp.OssManagement.Imaging.csproj index 5ff41456a..18e15c6d5 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN.Abp.OssManagement.Imaging.csproj @@ -1,12 +1,12 @@ - + net8.0 - LINGYUN.Abp.OssManagement.FileSystem.Imaging - LINGYUN.Abp.OssManagement.FileSystem.Imaging + LINGYUN.Abp.OssManagement.Imaging + LINGYUN.Abp.OssManagement.Imaging false false false @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpImagingProcesserContributor.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpImagingProcesserContributor.cs similarity index 79% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpImagingProcesserContributor.cs rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpImagingProcesserContributor.cs index e840cd7e5..cdf01d27e 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpImagingProcesserContributor.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpImagingProcesserContributor.cs @@ -3,27 +3,30 @@ using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using Volo.Abp.Http; using Volo.Abp.Imaging; -namespace LINGYUN.Abp.OssManagement.FileSystem.Imaging; -public class AbpImagingProcesserContributor : IFileSystemOssObjectProcesserContributor +namespace LINGYUN.Abp.OssManagement.Imaging; +public class AbpImagingProcesserContributor : IOssObjectProcesserContributor { - public async virtual Task ProcessAsync(FileSystemOssObjectContext context) + public async virtual Task ProcessAsync(OssObjectProcesserContext context) { Stream processSreeam = new MemoryStream(); var copyStream = context.OssObject.Content; await copyStream.CopyToAsync(processSreeam); copyStream.Seek(0, SeekOrigin.Begin); - var bytes = await copyStream.GetAllBytesAsync(); + var bytes = await processSreeam.GetAllBytesAsync(); if (bytes.IsImage()) { var args = context.Process.Split(','); + var mimeType = MimeTypes.GetByExtension(Path.GetExtension(context.OssObject.Name)); if (Resize(args, out var resizeArgs)) { + processSreeam.Seek(0, SeekOrigin.Begin); var imageResizer = context.ServiceProvider.GetRequiredService(); - var resizeResult = await imageResizer.ResizeAsync(processSreeam, resizeArgs); + var resizeResult = await imageResizer.ResizeAsync(processSreeam, resizeArgs, mimeType); if (resizeResult.State == ImageProcessState.Done) { processSreeam = resizeResult.Result; @@ -31,8 +34,9 @@ public class AbpImagingProcesserContributor : IFileSystemOssObjectProcesserContr } if (Compress(args)) { + processSreeam.Seek(0, SeekOrigin.Begin); var imageCompressor = context.ServiceProvider.GetRequiredService(); - var compressResult = await imageCompressor.CompressAsync(processSreeam); + var compressResult = await imageCompressor.CompressAsync(processSreeam, mimeType); if (compressResult.State == ImageProcessState.Done) { processSreeam = compressResult.Result; diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpOssManagementFileSystemImagingModule.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpOssManagementImagingModule.cs similarity index 57% rename from aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpOssManagementFileSystemImagingModule.cs rename to aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpOssManagementImagingModule.cs index ebe8496e6..dbd09dcdc 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.FileSystem.Imaging/LINGYUN/Abp/OssManagement/FileSystem/Imaging/AbpOssManagementFileSystemImagingModule.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Imaging/LINGYUN/Abp/OssManagement/Imaging/AbpOssManagementImagingModule.cs @@ -1,16 +1,16 @@ using Volo.Abp.Imaging; using Volo.Abp.Modularity; -namespace LINGYUN.Abp.OssManagement.FileSystem.Imaging; +namespace LINGYUN.Abp.OssManagement.Imaging; [DependsOn( typeof(AbpImagingAbstractionsModule), - typeof(AbpOssManagementFileSystemModule))] -public class AbpOssManagementFileSystemImagingModule : AbpModule + typeof(AbpOssManagementDomainModule))] +public class AbpOssManagementImagingModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => + Configure(options => { options.AddProcesser(new AbpImagingProcesserContributor()); }); diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainer.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainer.cs index 90b76d769..d6c6f7ee5 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainer.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainer.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Minio; using Minio.DataModel.Args; using Minio.DataModel.ILM; @@ -22,7 +24,7 @@ namespace LINGYUN.Abp.OssManagement.Minio; /// /// Oss容器的Minio实现 /// -public class MinioOssContainer : IOssContainer, IOssObjectExpireor +public class MinioOssContainer : OssContainerBase, IOssObjectExpireor { protected IMinioBlobNameCalculator MinioBlobNameCalculator { get; } protected IBlobNormalizeNamingService BlobNormalizeNamingService { get; } @@ -38,7 +40,10 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor ILogger logger, IMinioBlobNameCalculator minioBlobNameCalculator, IBlobNormalizeNamingService blobNormalizeNamingService, - IBlobContainerConfigurationProvider configurationProvider) + IBlobContainerConfigurationProvider configurationProvider, + IServiceScopeFactory serviceScopeFactory, + IOptions options) + : base(options, serviceScopeFactory) { Clock = clock; Logger = logger; @@ -48,7 +53,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor ConfigurationProvider = configurationProvider; } - public async virtual Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) + public async override Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) { var client = GetMinioClient(); @@ -76,7 +81,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor await tcs.Task; } - public async virtual Task CreateAsync(string name) + public async override Task CreateAsync(string name) { var client = GetMinioClient(); @@ -97,7 +102,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor new Dictionary()); } - public async virtual Task CreateObjectAsync(CreateOssObjectRequest request) + public async override Task CreateObjectAsync(CreateOssObjectRequest request) { var client = GetMinioClient(); @@ -176,46 +181,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor return ossObject; } - public async virtual Task DeleteAsync(string name) - { - var client = GetMinioClient(); - var bucket = GetBucket(name); - - if (!await BucketExists(client, bucket)) - { - throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); - } - - // 非空目录无法删除 - var tcs = new TaskCompletionSource(); - var listObjectObs = client.ListObjectsAsync( - new ListObjectsArgs() - .WithBucket(bucket)); - - var listObjects = new List(); - using var _ = listObjectObs.Subscribe( - (item) => - { - listObjects.Add(item.Key); - tcs.TrySetResult(true); - }, - (ex) => tcs.TrySetException(ex), - () => tcs.TrySetResult(true)); - - await tcs.Task; - - if (listObjects.Count > 0) - { - throw new BusinessException(code: OssManagementErrorCodes.ContainerDeleteWithNotEmpty); - } - - var deleteBucketArgs = new RemoveBucketArgs() - .WithBucket(bucket); - - await client.RemoveBucketAsync(deleteBucketArgs); - } - - public async virtual Task DeleteObjectAsync(GetOssObjectRequest request) + public async override Task DeleteObjectAsync(GetOssObjectRequest request) { if (request.Object.EndsWith('/')) { @@ -245,7 +211,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor } } - public async virtual Task ExistsAsync(string name) + public async override Task ExistsAsync(string name) { var client = GetMinioClient(); @@ -297,7 +263,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor } } - public async virtual Task GetAsync(string name) + public async override Task GetAsync(string name) { var client = GetMinioClient(); @@ -319,7 +285,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor new Dictionary()); } - public async virtual Task GetListAsync(GetOssContainersRequest request) + public async override Task GetListAsync(GetOssContainersRequest request) { var client = GetMinioClient(); @@ -347,70 +313,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor resultObjects); } - public async virtual Task GetObjectAsync(GetOssObjectRequest request) - { - var client = GetMinioClient(); - - var bucket = GetBucket(request.Bucket); - - var prefixPath = GetPrefixPath(); - var objectPath = GetBlobPath(prefixPath, request.Path); - var objectName = objectPath.IsNullOrWhiteSpace() - ? request.Object - : objectPath.EnsureEndsWith('/') + request.Object; - - if (!await ObjectExists(client, bucket, objectName)) - { - throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); - } - - var memoryStream = new MemoryStream(); - var getObjectArgs = new GetObjectArgs() - .WithBucket(bucket) - .WithObject(objectName) - .WithCallbackStream((stream) => - { - if (stream != null) - { - stream.CopyTo(memoryStream); - memoryStream.Seek(0, SeekOrigin.Begin); - } - else - { - memoryStream = null; - } - }); - var getObjectResult = await client.GetObjectAsync(getObjectArgs); - - var ossObject = new OssObject( - !objectPath.IsNullOrWhiteSpace() - ? getObjectResult.ObjectName.Replace(objectPath, "") - : getObjectResult.ObjectName, - request.Path, - getObjectResult.ETag, - getObjectResult.LastModified, - memoryStream.Length, - getObjectResult.LastModified, - getObjectResult.MetaData, - getObjectResult.ObjectName.EndsWith("/")) - { - FullName = getObjectResult.ObjectName.Replace(prefixPath, "") - }; - - if (memoryStream.Length > 0) - { - ossObject.SetContent(memoryStream); - } - - if (!request.Process.IsNullOrWhiteSpace()) - { - // TODO: 文件流处理 - } - - return ossObject; - } - - public async virtual Task GetObjectsAsync(GetOssObjectsRequest request) + public async override Task GetObjectsAsync(GetOssObjectsRequest request) { var client = GetMinioClient(); @@ -431,7 +334,7 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor var listObjectResult = client.ListObjectsAsync(listObjectArgs); var resultObjects = new List(); - + using var _ = listObjectResult.Subscribe( onNext: (item) => { @@ -476,6 +379,103 @@ public class MinioOssContainer : IOssContainer, IOssObjectExpireor resultObjects); } + protected async override Task DeleteBucketAsync(string name) + { + var client = GetMinioClient(); + var bucket = GetBucket(name); + + if (!await BucketExists(client, bucket)) + { + throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); + } + + // 非空目录无法删除 + var tcs = new TaskCompletionSource(); + var listObjectObs = client.ListObjectsAsync( + new ListObjectsArgs() + .WithBucket(bucket)); + + var listObjects = new List(); + using var _ = listObjectObs.Subscribe( + (item) => + { + listObjects.Add(item.Key); + tcs.TrySetResult(true); + }, + (ex) => tcs.TrySetException(ex), + () => tcs.TrySetResult(true)); + + await tcs.Task; + + if (listObjects.Count > 0) + { + throw new BusinessException(code: OssManagementErrorCodes.ContainerDeleteWithNotEmpty); + } + + var deleteBucketArgs = new RemoveBucketArgs() + .WithBucket(bucket); + + await client.RemoveBucketAsync(deleteBucketArgs); + } + + protected async override Task GetOssObjectAsync(GetOssObjectRequest request) + { + var client = GetMinioClient(); + + var bucket = GetBucket(request.Bucket); + + var prefixPath = GetPrefixPath(); + var objectPath = GetBlobPath(prefixPath, request.Path); + var objectName = objectPath.IsNullOrWhiteSpace() + ? request.Object + : objectPath.EnsureEndsWith('/') + request.Object; + + if (!await ObjectExists(client, bucket, objectName)) + { + throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); + } + + var memoryStream = new MemoryStream(); + var getObjectArgs = new GetObjectArgs() + .WithBucket(bucket) + .WithObject(objectName) + .WithCallbackStream((stream) => + { + if (stream != null) + { + stream.CopyTo(memoryStream); + memoryStream.Seek(0, SeekOrigin.Begin); + } + else + { + memoryStream = null; + } + }); + var getObjectResult = await client.GetObjectAsync(getObjectArgs); + + var ossObject = new OssObject( + !objectPath.IsNullOrWhiteSpace() + ? getObjectResult.ObjectName.Replace(objectPath, "") + : getObjectResult.ObjectName, + request.Path, + getObjectResult.ETag, + getObjectResult.LastModified, + memoryStream.Length, + getObjectResult.LastModified, + getObjectResult.MetaData, + getObjectResult.ObjectName.EndsWith("/")) + { + FullName = getObjectResult.ObjectName.Replace(prefixPath, "") + }; + + if (memoryStream.Length > 0) + { + ossObject.SetContent(memoryStream); + } + + return ossObject; + } + protected virtual IMinioClient GetMinioClient() { var configuration = GetMinioConfiguration(); diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainerFactory.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainerFactory.cs index 90ae1358f..cd0c9a28e 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainerFactory.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Minio/LINGYUN/Abp/OssManagement/Minio/MinioOssContainerFactory.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.Minio; using Volo.Abp.MultiTenancy; @@ -15,17 +17,24 @@ public class MinioOssContainerFactory : IOssContainerFactory protected ICurrentTenant CurrentTenant { get; } protected ILogger Logger { get; } + protected IServiceScopeFactory ServiceScopeFactory { get; } + protected IOptions Options { get; } + public MinioOssContainerFactory( - IClock clock, + IClock clock, ICurrentTenant currentTenant, - ILogger logger, - IMinioBlobNameCalculator minioBlobNameCalculator, - IBlobNormalizeNamingService blobNormalizeNamingService, - IBlobContainerConfigurationProvider configurationProvider) + ILogger logger, + IMinioBlobNameCalculator minioBlobNameCalculator, + IBlobNormalizeNamingService blobNormalizeNamingService, + IBlobContainerConfigurationProvider configurationProvider, + IServiceScopeFactory serviceScopeFactory, + IOptions options) { Clock = clock; Logger = logger; CurrentTenant = currentTenant; + Options = options; + ServiceScopeFactory = serviceScopeFactory; MinioBlobNameCalculator = minioBlobNameCalculator; BlobNormalizeNamingService = blobNormalizeNamingService; ConfigurationProvider = configurationProvider; @@ -39,6 +48,8 @@ public class MinioOssContainerFactory : IOssContainerFactory Logger, MinioBlobNameCalculator, BlobNormalizeNamingService, - ConfigurationProvider); + ConfigurationProvider, + ServiceScopeFactory, + Options); } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainer.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainer.cs index 07c80c134..85e06ec8f 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainer.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainer.cs @@ -5,6 +5,8 @@ using LINGYUN.Abp.Sonatype.Nexus.Search; using LINGYUN.Abp.Sonatype.Nexus.Services.CoreUI; using LINGYUN.Abp.Sonatype.Nexus.Services.CoreUI.Assets; using LINGYUN.Abp.Sonatype.Nexus.Services.CoreUI.Browsers; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.IO; @@ -17,7 +19,7 @@ using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.OssManagement.Nexus; -internal class NexusOssContainer : IOssContainer, IOssObjectExpireor +internal class NexusOssContainer : OssContainerBase, IOssObjectExpireor { protected ICoreUiServiceProxy CoreUiServiceProxy { get; } protected INexusAssetManager NexusAssetManager { get; } @@ -34,7 +36,10 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor INexusLookupService nexusLookupService, ICurrentTenant currentTenant, IBlobRawPathCalculator blobRawPathCalculator, - IBlobContainerConfigurationProvider configurationProvider) + IBlobContainerConfigurationProvider configurationProvider, + IServiceScopeFactory serviceScopeFactory, + IOptions options) + : base(options, serviceScopeFactory) { CoreUiServiceProxy = coreUiServiceProxy; NexusAssetManager = nexusAssetManager; @@ -45,12 +50,12 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor ConfigurationProvider = configurationProvider; } - public Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) + public override Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) { throw new NotImplementedException(); } - public async virtual Task CreateAsync(string name) + public async override Task CreateAsync(string name) { // 创建容器的逻辑就是创建一个包含一个空白assets的component @@ -72,7 +77,7 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor DateTime.Now); } - public async virtual Task CreateObjectAsync(CreateOssObjectRequest request) + public async override Task CreateObjectAsync(CreateOssObjectRequest request) { var nexusConfiguration = GetNexusConfiguration(); var blobPath = GetBasePath(request.Bucket, request.Path, request.Object); @@ -106,27 +111,7 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor return await GetObjectAsync(getOssObjectRequest); } - public async virtual Task DeleteAsync(string name) - { - var nexusConfiguration = GetNexusConfiguration(); - var blobPath = BlobRawPathCalculator.CalculateGroup(name, "/"); - - var nexusSearchArgs = new NexusSearchArgs( - nexusConfiguration.Repository, - blobPath, - "/"); - - var nexusComponentListResult = await NexusLookupService.ListComponentAsync(nexusSearchArgs); - var nexusComponent = nexusComponentListResult.Items.FirstOrDefault(); - if (nexusComponent == null) - { - throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); - } - - await NexusComponentManager.DeleteAsync(nexusComponent.Id); - } - - public async virtual Task DeleteObjectAsync(GetOssObjectRequest request) + public async override Task DeleteObjectAsync(GetOssObjectRequest request) { var nexusConfiguration = GetNexusConfiguration(); var blobPath = GetBasePath(request.Bucket, request.Path, request.Object); @@ -145,17 +130,17 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor } } - public virtual Task ExistsAsync(string name) + public override Task ExistsAsync(string name) { throw new NotImplementedException(); } - public Task ExpireAsync(ExprieOssObjectRequest request) + public virtual Task ExpireAsync(ExprieOssObjectRequest request) { throw new NotImplementedException(); } - public async virtual Task GetAsync(string name) + public async override Task GetAsync(string name) { var nexusConfiguration = GetNexusConfiguration(); var blobPath = BlobRawPathCalculator.CalculateGroup(name, "/"); @@ -184,7 +169,7 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor lastModified); } - public async virtual Task GetListAsync(GetOssContainersRequest request) + public async override Task GetListAsync(GetOssContainersRequest request) { var nexusConfiguration = GetNexusConfiguration(); var blobPath = request.Prefix.RemovePreFix(".").RemovePreFix("/"); @@ -208,7 +193,65 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor .ToList()); } - public async virtual Task GetObjectAsync(GetOssObjectRequest request) + public async override Task GetObjectsAsync(GetOssObjectsRequest request) + { + var nexusConfiguration = GetNexusConfiguration(); + var blobPath = GetBasePath(request.BucketName, request.Prefix, ""); + var readComponent = CoreUIBrowse.Read(nexusConfiguration.Repository, blobPath.RemovePreFix("/")); + + var coreUIResponse = await CoreUiServiceProxy.SearchAsync(readComponent); + var filterComponents = coreUIResponse.Result.Data + .WhereIf(string.Equals(request.Delimiter, "/"), component => component.Type == "folder") + .OrderBy(component => component.Text) + .AsQueryable() + .PageBy(request.Current, request.MaxKeys ?? 10) + .ToArray(); + + var response = new GetOssObjectsResponse( + request.BucketName, + request.Prefix, + request.Marker, + "", + "/", // 文件系统目录分隔符 + coreUIResponse.Result.Data.Count, + filterComponents.Select(component => new OssObject( + component.Text, + request.Prefix, + "", + null, + 0L, + null, + new Dictionary(), + component.Type == "folder") + { + FullName = component.Id + }) + .ToList()); + + return response; + } + + protected async override Task DeleteBucketAsync(string name) + { + var nexusConfiguration = GetNexusConfiguration(); + var blobPath = BlobRawPathCalculator.CalculateGroup(name, "/"); + + var nexusSearchArgs = new NexusSearchArgs( + nexusConfiguration.Repository, + blobPath, + "/"); + + var nexusComponentListResult = await NexusLookupService.ListComponentAsync(nexusSearchArgs); + var nexusComponent = nexusComponentListResult.Items.FirstOrDefault(); + if (nexusComponent == null) + { + throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); + } + + await NexusComponentManager.DeleteAsync(nexusComponent.Id); + } + + protected async override Task GetOssObjectAsync(GetOssObjectRequest request) { var nexusConfiguration = GetNexusConfiguration(); var blobPath = GetBasePath(request.Bucket, request.Path, request.Object); @@ -253,44 +296,6 @@ internal class NexusOssContainer : IOssContainer, IOssObjectExpireor ); } - public async virtual Task GetObjectsAsync(GetOssObjectsRequest request) - { - var nexusConfiguration = GetNexusConfiguration(); - var blobPath = GetBasePath(request.BucketName, request.Prefix, ""); - var readComponent = CoreUIBrowse.Read(nexusConfiguration.Repository, blobPath.RemovePreFix("/")); - - var coreUIResponse = await CoreUiServiceProxy.SearchAsync(readComponent); - var filterComponents = coreUIResponse.Result.Data - .WhereIf(string.Equals(request.Delimiter, "/"), component => component.Type == "folder") - .OrderBy(component => component.Text) - .AsQueryable() - .PageBy(request.Current, request.MaxKeys ?? 10) - .ToArray(); - - var response = new GetOssObjectsResponse( - request.BucketName, - request.Prefix, - request.Marker, - "", - "/", // 文件系统目录分隔符 - coreUIResponse.Result.Data.Count, - filterComponents.Select(component => new OssObject( - component.Text, - request.Prefix, - "", - null, - 0L, - null, - new Dictionary(), - component.Type == "folder") - { - FullName = component.Id - }) - .ToList()); - - return response; - } - protected virtual NexusBlobProviderConfiguration GetNexusConfiguration() { var configuration = ConfigurationProvider.Get(); diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainerFactory.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainerFactory.cs index de29b88a5..827d886d8 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainerFactory.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Nexus/LINGYUN/Abp/OssManagement/Nexus/NexusOssContainerFactory.cs @@ -3,6 +3,8 @@ using LINGYUN.Abp.Sonatype.Nexus.Assets; using LINGYUN.Abp.Sonatype.Nexus.Components; using LINGYUN.Abp.Sonatype.Nexus.Search; using LINGYUN.Abp.Sonatype.Nexus.Services.CoreUI; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Volo.Abp.BlobStoring; using Volo.Abp.MultiTenancy; @@ -17,6 +19,9 @@ internal class NexusOssContainerFactory : IOssContainerFactory protected IBlobRawPathCalculator BlobRawPathCalculator { get; } protected IBlobContainerConfigurationProvider ConfigurationProvider { get; } + protected IServiceScopeFactory ServiceScopeFactory { get; } + protected IOptions Options { get; } + public NexusOssContainerFactory( ICoreUiServiceProxy coreUiServiceProxy, INexusAssetManager nexusAssetManager, @@ -24,7 +29,9 @@ internal class NexusOssContainerFactory : IOssContainerFactory INexusLookupService nexusLookupService, ICurrentTenant currentTenant, IBlobRawPathCalculator blobRawPathCalculator, - IBlobContainerConfigurationProvider configurationProvider) + IBlobContainerConfigurationProvider configurationProvider, + IServiceScopeFactory serviceScopeFactory, + IOptions options) { CoreUiServiceProxy = coreUiServiceProxy; NexusAssetManager = nexusAssetManager; @@ -33,6 +40,8 @@ internal class NexusOssContainerFactory : IOssContainerFactory CurrentTenant = currentTenant; BlobRawPathCalculator = blobRawPathCalculator; ConfigurationProvider = configurationProvider; + Options = options; + ServiceScopeFactory = serviceScopeFactory; } public IOssContainer Create() @@ -44,6 +53,8 @@ internal class NexusOssContainerFactory : IOssContainerFactory NexusLookupService, CurrentTenant, BlobRawPathCalculator, - ConfigurationProvider); + ConfigurationProvider, + ServiceScopeFactory, + Options); } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainer.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainer.cs index ee329d1d7..d39ddfcca 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainer.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainer.cs @@ -3,6 +3,8 @@ using COSXML.Model.Bucket; using COSXML.Model.Object; using COSXML.Model.Service; using LINGYUN.Abp.BlobStoring.Tencent; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.IO; @@ -17,7 +19,7 @@ namespace LINGYUN.Abp.OssManagement.Tencent; /// /// Oss容器的阿里云实现 /// -internal class TencentOssContainer : IOssContainer, IOssObjectExpireor +internal class TencentOssContainer : OssContainerBase, IOssObjectExpireor { protected IClock Clock { get; } protected ICurrentTenant CurrentTenant { get; } @@ -25,13 +27,16 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor public TencentOssContainer( IClock clock, ICurrentTenant currentTenant, - ICosClientFactory cosClientFactory) + ICosClientFactory cosClientFactory, + IServiceScopeFactory serviceScopeFactory, + IOptions options) + : base(options, serviceScopeFactory) { Clock = clock; CurrentTenant = currentTenant; CosClientFactory = cosClientFactory; } - public async virtual Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) + public async override Task BulkDeleteObjectsAsync(BulkDeleteObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -42,7 +47,7 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor ossClient.DeleteMultiObjects(deleteRequest); } - public async virtual Task CreateAsync(string name) + public async override Task CreateAsync(string name) { var ossClient = await CreateClientAsync(); @@ -66,7 +71,7 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor }); } - public async virtual Task CreateObjectAsync(CreateOssObjectRequest request) + public async override Task CreateObjectAsync(CreateOssObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -146,19 +151,6 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor return ossObject; } - public async virtual Task DeleteAsync(string name) - { - // 阿里云oss在控制台设置即可,无需改变 - var ossClient = await CreateClientAsync(); - - if (!BucketExists(ossClient, name)) - { - throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); - } - var deleteBucketRequest = new DeleteBucketRequest(name); - ossClient.DeleteBucket(deleteBucketRequest); - } - public async virtual Task ExpireAsync(ExprieOssObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -186,7 +178,7 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor } } - public async virtual Task DeleteObjectAsync(GetOssObjectRequest request) + public async override Task DeleteObjectAsync(GetOssObjectRequest request) { var ossClient = await CreateClientAsync(); @@ -212,14 +204,14 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor } } - public async virtual Task ExistsAsync(string name) + public async override Task ExistsAsync(string name) { var ossClient = await CreateClientAsync(); return BucketExists(ossClient, name); } - public async virtual Task GetAsync(string name) + public async override Task GetAsync(string name) { var ossClient = await CreateClientAsync(); if (!BucketExists(ossClient, name)) @@ -242,59 +234,7 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor }); } - public async virtual Task GetObjectAsync(GetOssObjectRequest request) - { - var ossClient = await CreateClientAsync(); - if (!BucketExists(ossClient, request.Bucket)) - { - throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); - // throw new ContainerNotFoundException($"Can't not found container {request.Bucket} in aliyun blob storing"); - } - - var objectPath = GetBasePath(request.Path); - var objectName = objectPath.IsNullOrWhiteSpace() - ? request.Object - : objectPath + request.Object; - - if (!ObjectExists(ossClient, request.Bucket, objectName)) - { - throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); - // throw new ContainerNotFoundException($"Can't not found object {objectName} in container {request.Bucket} with aliyun blob storing"); - } - - var getObjectRequest = new GetObjectBytesRequest(request.Bucket, objectName); - if (!request.Process.IsNullOrWhiteSpace()) - { - getObjectRequest.SetQueryParameter(request.Process, null); - } - var objectResult = ossClient.GetObject(getObjectRequest); - var ossObject = new OssObject( - !objectPath.IsNullOrWhiteSpace() - ? objectResult.Key.Replace(objectPath, "") - : objectResult.Key, - request.Path, - objectResult.eTag, - null, - objectResult.content.Length, - null, - new Dictionary(), - objectResult.Key.EndsWith("/")) - { - FullName = objectResult.Key - }; - - if (objectResult.content.Length > 0) - { - var memoryStream = new MemoryStream(); - await memoryStream.WriteAsync(objectResult.content, 0, objectResult.content.Length); - memoryStream.Seek(0, SeekOrigin.Begin); - ossObject.SetContent(memoryStream); - } - - return ossObject; - } - - public async virtual Task GetListAsync(GetOssContainersRequest request) + public async override Task GetListAsync(GetOssContainersRequest request) { var ossClient = await CreateClientAsync(); @@ -321,7 +261,7 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor .ToList()); } - public async virtual Task GetObjectsAsync(GetOssObjectsRequest request) + public async override Task GetObjectsAsync(GetOssObjectsRequest request) { var ossClient = await CreateClientAsync(); @@ -394,6 +334,71 @@ internal class TencentOssContainer : IOssContainer, IOssObjectExpireor ossObjects); } + protected async override Task DeleteBucketAsync(string name) + { + // 腾讯云oss在控制台设置即可,无需改变 + var ossClient = await CreateClientAsync(); + + if (!BucketExists(ossClient, name)) + { + throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); + } + var deleteBucketRequest = new DeleteBucketRequest(name); + ossClient.DeleteBucket(deleteBucketRequest); + } + + protected async override Task GetOssObjectAsync(GetOssObjectRequest request) + { + var ossClient = await CreateClientAsync(); + if (!BucketExists(ossClient, request.Bucket)) + { + throw new BusinessException(code: OssManagementErrorCodes.ContainerNotFound); + // throw new ContainerNotFoundException($"Can't not found container {request.Bucket} in aliyun blob storing"); + } + + var objectPath = GetBasePath(request.Path); + var objectName = objectPath.IsNullOrWhiteSpace() + ? request.Object + : objectPath + request.Object; + + if (!ObjectExists(ossClient, request.Bucket, objectName)) + { + throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); + // throw new ContainerNotFoundException($"Can't not found object {objectName} in container {request.Bucket} with aliyun blob storing"); + } + + var getObjectRequest = new GetObjectBytesRequest(request.Bucket, objectName); + if (!request.Process.IsNullOrWhiteSpace()) + { + getObjectRequest.SetQueryParameter(request.Process, null); + } + var objectResult = ossClient.GetObject(getObjectRequest); + var ossObject = new OssObject( + !objectPath.IsNullOrWhiteSpace() + ? objectResult.Key.Replace(objectPath, "") + : objectResult.Key, + request.Path, + objectResult.eTag, + null, + objectResult.content.Length, + null, + new Dictionary(), + objectResult.Key.EndsWith("/")) + { + FullName = objectResult.Key + }; + + if (objectResult.content.Length > 0) + { + var memoryStream = new MemoryStream(); + await memoryStream.WriteAsync(objectResult.content, 0, objectResult.content.Length); + memoryStream.Seek(0, SeekOrigin.Begin); + ossObject.SetContent(memoryStream); + } + + return ossObject; + } + protected virtual string GetBasePath(string path) { string objectPath = ""; diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainerFactory.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainerFactory.cs index ac4cc41ce..625a736dd 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainerFactory.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/LINGYUN/Abp/OssManagement/Tencent/TencentOssContainerFactory.cs @@ -1,30 +1,41 @@ -using LINGYUN.Abp.BlobStoring.Tencent; -using Volo.Abp.MultiTenancy; +using LINGYUN.Abp.BlobStoring.Tencent; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.MultiTenancy; using Volo.Abp.Timing; -namespace LINGYUN.Abp.OssManagement.Tencent; - -public class TencentOssContainerFactory : IOssContainerFactory -{ - protected IClock Clock { get; } - protected ICurrentTenant CurrentTenant { get; } - protected ICosClientFactory CosClientFactory { get; } - - public TencentOssContainerFactory( - IClock clock, - ICurrentTenant currentTenant, - ICosClientFactory cosClientFactory) - { - Clock = clock; - CurrentTenant = currentTenant; - CosClientFactory = cosClientFactory; - } - - public IOssContainer Create() - { - return new TencentOssContainer( - Clock, - CurrentTenant, - CosClientFactory); - } -} +namespace LINGYUN.Abp.OssManagement.Tencent; + +public class TencentOssContainerFactory : IOssContainerFactory +{ + protected IClock Clock { get; } + protected ICurrentTenant CurrentTenant { get; } + protected ICosClientFactory CosClientFactory { get; } + + protected IServiceScopeFactory ServiceScopeFactory { get; } + protected IOptions Options { get; } + + public TencentOssContainerFactory( + IClock clock, + ICurrentTenant currentTenant, + ICosClientFactory cosClientFactory, + IServiceScopeFactory serviceScopeFactory, + IOptions options) + { + Clock = clock; + CurrentTenant = currentTenant; + CosClientFactory = cosClientFactory; + Options = options; + ServiceScopeFactory = serviceScopeFactory; + } + + public IOssContainer Create() + { + return new TencentOssContainer( + Clock, + CurrentTenant, + CosClientFactory, + ServiceScopeFactory, + Options); + } +} diff --git a/aspnet-core/modules/oss-management/README.md b/aspnet-core/modules/oss-management/README.md index 95fcf46d4..047df60b7 100644 --- a/aspnet-core/modules/oss-management/README.md +++ b/aspnet-core/modules/oss-management/README.md @@ -17,12 +17,14 @@ File-Management更名为Oss-Management ### 高阶模块 * [LINGYUN.Abp.BlobStoring.OssManagement](./LINGYUN.Abp.BlobStoring.OssManagement) abp框架对象存储提供者**IBlobProvider**的Oss管理模块实现, 依赖于Oss客户端代理模块 -* [LINGYUN.Abp.OssManagement.Aliyun](./LINGYUN.Abp.OssManagement.Aliyun) Oss管理的阿里云实现,实现了部分阿里云Oss服务的容器与对象管理 -* [LINGYUN.Abp.OssManagement.FileSystem](./LINGYUN.Abp.OssManagement.FileSystem) Oss管理的本地文件系统实现,实现了部分本地文件系统的容器(目录)与对象(文件/目录)管理 -* [LINGYUN.Abp.OssManagement.FileSystem.ImageSharp](./LINGYUN.Abp.OssManagement.FileSystem.ImageSharp) Oss本地对象的ImageSharp扩展,当前端传递需求处理对象时,此模块用于实现基于图形文件流的处理 -* [LINGYUN.Abp.OssManagement.FileSystem.Imaging](./LINGYUN.Abp.OssManagement.FileSystem.Imaging) Oss本地对象的Volo.Abp.Imaging扩展 -* [LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp](./LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp) Oss本地对象的Volo.Abp.Imaging.ImageSharp扩展 +* [LINGYUN.Abp.OssManagement.Aliyun](./LINGYUN.Abp.OssManagement.Aliyun) Oss管理的阿里云实现,实现了部分阿里云Oss服务的容器与对象管理 +* [LINGYUN.Abp.OssManagement.FileSystem](./LINGYUN.Abp.OssManagement.FileSystem) Oss管理的本地文件系统实现,实现了部分本地文件系统的容器(目录)与对象(文件/目录)管理 +* [LINGYUN.Abp.OssManagement.ImageSharp](./LINGYUN.Abp.OssManagement.ImageSharp) Oss对象的ImageSharp扩展,当前端传递需求处理对象时,此模块用于实现基于图形文件流的处理 +* [LINGYUN.Abp.OssManagement.Imaging](./LINGYUN.Abp.OssManagement.Imaging) Oss对象的Volo.Abp.Imaging扩展 +* [LINGYUN.Abp.OssManagement.Imaging.ImageSharp](./LINGYUN.Abp.OssManagement.Imaging.ImageSharp) Oss对象的Volo.Abp.Imaging.ImageSharp扩展 * [LINGYUN.Abp.OssManagement.Nexus](./LINGYUN.Abp.OssManagement.Nexus) Oss管理的Nexus实现,管理来自私有Nexus仓库的RAW存储类型 +* [LINGYUN.Abp.OssManagement.Minio](./LINGYUN.Abp.OssManagement.Minio) Oss管理的Minio实现,管理基于Minio的对象存储服务 +* [LINGYUN.Abp.OssManagement.Tencent](./LINGYUN.Abp.OssManagement.Tencent) Oss管理的腾讯云实现,实现了部分腾讯云Oss服务的容器与对象管理(未完全实现) ### 权限定义 @@ -56,4 +58,5 @@ File-Management更名为Oss-Management *【2021-10-22】 增加PublicFilesController用于身份认证通过的用户上传/下载文件,所有操作限定在用户目录下 *【2021-12-13】 增加LINGYUN.Abp.BlobStoring.OssManagement用于实现Oss代理二进制文件存储 *【2023-09-04】 集成Volo.Abp.Imaging模块用于图形文件流处理 -*【2023-10-11】 集成Nexus仓库实现基于Nexus Raw类型存储(**未完善**) \ No newline at end of file +*【2023-10-11】 集成Nexus仓库实现基于Nexus Raw类型存储(**未完善**) +*【2024-10-24】 集成Volo.Abp.BlobStoring.Minio模块用于实现基于Minio的文件存储 \ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj b/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj index 98101e714..a2a158252 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj +++ b/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj @@ -170,6 +170,7 @@ + @@ -203,9 +204,8 @@ - - + diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs index 330796a07..d9d66bc79 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs @@ -60,6 +60,7 @@ using Volo.Abp.Auditing; using Volo.Abp.Authorization.Permissions; using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.FileSystem; +using Volo.Abp.BlobStoring.Minio; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.FeatureManagement; diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs index ca7aaa23a..1a29f288c 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs @@ -69,7 +69,9 @@ using LINGYUN.Abp.OpenIddict.Sms; using LINGYUN.Abp.OpenIddict.WeChat; using LINGYUN.Abp.OpenIddict.WeChat.Work; using LINGYUN.Abp.OssManagement; -using LINGYUN.Abp.OssManagement.FileSystem.ImageSharp; +using LINGYUN.Abp.OssManagement.FileSystem; +using LINGYUN.Abp.OssManagement.Imaging.ImageSharp; +using LINGYUN.Abp.OssManagement.Minio; using LINGYUN.Abp.OssManagement.SettingManagement; using LINGYUN.Abp.PermissionManagement; using LINGYUN.Abp.PermissionManagement.HttpApi; @@ -175,8 +177,9 @@ namespace LY.MicroService.Applications.Single; typeof(AbpOpenIddictWeChatModule), typeof(AbpOpenIddictWeChatWorkModule), - // typeof(AbpOssManagementMinioModule), // 取消注释以使用Minio - typeof(AbpOssManagementFileSystemImageSharpModule), + //typeof(AbpOssManagementMinioModule), // 取消注释以使用Minio + typeof(AbpOssManagementFileSystemModule), + typeof(AbpOssManagementImagingImageSharpModule), typeof(AbpOssManagementDomainModule), typeof(AbpOssManagementApplicationModule), typeof(AbpOssManagementHttpApiModule),