29 changed files with 368 additions and 89 deletions
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<packageSources> |
|||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> |
|||
<add key="LocalNuget" value="./LocalNuget" /> |
|||
</packageSources> |
|||
</configuration> |
|||
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
public abstract class GetFileMultiTenancyInput |
|||
{ |
|||
/// <summary>
|
|||
/// 解决通过路由传递租户标识时,abp写入cookies
|
|||
/// </summary>
|
|||
public string TenantId { get; set; } |
|||
|
|||
public virtual Guid? GetTenantId(ICurrentTenant currentTenant) |
|||
{ |
|||
if (!TenantId.IsNullOrWhiteSpace()) |
|||
{ |
|||
if ("global".Equals(TenantId, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
return null; |
|||
} |
|||
if (Guid.TryParse(TenantId, out var tenantId)) |
|||
{ |
|||
return tenantId; |
|||
} |
|||
} |
|||
return currentTenant.Id; |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,12 @@ |
|||
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 |
|||
{ |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Imaging.ImageSharp" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.OssManagement.FileSystem.Imaging\LINGYUN.Abp.OssManagement.FileSystem.Imaging.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Imaging.Abstractions" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.OssManagement.FileSystem\LINGYUN.Abp.OssManagement.FileSystem.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,75 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Imaging; |
|||
|
|||
namespace LINGYUN.Abp.OssManagement.FileSystem.Imaging; |
|||
public class AbpImagingProcesserContributor : IFileSystemOssObjectProcesserContributor |
|||
{ |
|||
public async virtual Task ProcessAsync(FileSystemOssObjectContext context) |
|||
{ |
|||
Stream processSreeam = new MemoryStream(); |
|||
var copyStream = context.OssObject.Content; |
|||
await copyStream.CopyToAsync(processSreeam); |
|||
copyStream.Seek(0, SeekOrigin.Begin); |
|||
var bytes = await copyStream.GetAllBytesAsync(); |
|||
|
|||
if (bytes.IsImage()) |
|||
{ |
|||
var args = context.Process.Split(','); |
|||
|
|||
if (Resize(args, out var resizeArgs)) |
|||
{ |
|||
var imageResizer = context.ServiceProvider.GetRequiredService<IImageResizer>(); |
|||
var resizeResult = await imageResizer.ResizeAsync(processSreeam, resizeArgs); |
|||
if (resizeResult.State == ImageProcessState.Done) |
|||
{ |
|||
processSreeam = resizeResult.Result; |
|||
} |
|||
} |
|||
if (Compress(args)) |
|||
{ |
|||
var imageCompressor = context.ServiceProvider.GetRequiredService<IImageCompressor>(); |
|||
var compressResult = await imageCompressor.CompressAsync(processSreeam); |
|||
if (compressResult.State == ImageProcessState.Done) |
|||
{ |
|||
processSreeam = compressResult.Result; |
|||
} |
|||
} |
|||
if (processSreeam.Length != copyStream.Length) |
|||
{ |
|||
context.SetContent(processSreeam); |
|||
// 释放原图形流数据
|
|||
await copyStream.DisposeAsync(); |
|||
} |
|||
else |
|||
{ |
|||
await processSreeam.DisposeAsync(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected virtual bool Resize(string[] args, out ImageResizeArgs resizeArgs) |
|||
{ |
|||
// 大小
|
|||
var width = args.GetInt32Prarm("w_"); |
|||
var height = args.GetInt32Prarm("h_"); |
|||
if (!width.IsNullOrWhiteSpace() && |
|||
!height.IsNullOrWhiteSpace()) |
|||
{ |
|||
resizeArgs = new ImageResizeArgs( |
|||
int.Parse(width), |
|||
int.Parse(height)); |
|||
return true; |
|||
} |
|||
resizeArgs = null; |
|||
return false; |
|||
} |
|||
|
|||
protected virtual bool Compress(string[] args) |
|||
{ |
|||
return args.Contains("cm"); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using Volo.Abp.Imaging; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.OssManagement.FileSystem.Imaging; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpImagingAbstractionsModule), |
|||
typeof(AbpOssManagementFileSystemModule))] |
|||
public class AbpOssManagementFileSystemImagingModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<FileSystemOssOptions>(options => |
|||
{ |
|||
options.AddProcesser(new AbpImagingProcesserContributor()); |
|||
}); |
|||
} |
|||
} |
|||
@ -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)); |
|||
} |
|||
} |
|||
@ -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 _)); |
|||
} |
|||
} |
|||
@ -1,33 +1,49 @@ |
|||
<Project> |
|||
<PropertyGroup> |
|||
<AgileConfigClientPackageVersion>1.6.9</AgileConfigClientPackageVersion> |
|||
<VoloAbpPackageVersion>7.2.2</VoloAbpPackageVersion> |
|||
<LINGYUNAbpPackageVersion>7.2.2</LINGYUNAbpPackageVersion> |
|||
<DotNetCoreCAPPackageVersion>7.1.0</DotNetCoreCAPPackageVersion> |
|||
<DaprPackageVersion>1.10.0</DaprPackageVersion> |
|||
<VoloAbpPackageVersion>7.3.2</VoloAbpPackageVersion> |
|||
<VoloAbpLeptonXThemePackageVersion>2.3.2</VoloAbpLeptonXThemePackageVersion> |
|||
<LINGYUNAbpPackageVersion>7.3.2</LINGYUNAbpPackageVersion> |
|||
<DaprPackageVersion>1.11.0</DaprPackageVersion> |
|||
<DistributedLockRedisPackageVersion>1.0.2</DistributedLockRedisPackageVersion> |
|||
<DotNetCoreCAPPackageVersion>7.2.0</DotNetCoreCAPPackageVersion> |
|||
<ElsaPackageVersion>2.11.0</ElsaPackageVersion> |
|||
<AliyunSDKPackageVersion>1.5.10</AliyunSDKPackageVersion> |
|||
<AliyunOSSSDKPackageVersion>2.13.0</AliyunOSSSDKPackageVersion> |
|||
<TencentCloudSDKPackageVersion>3.0.712</TencentCloudSDKPackageVersion> |
|||
<AgileConfigClientPackageVersion>1.6.9</AgileConfigClientPackageVersion> |
|||
<HangfireMySqlStoragePackageVersion>2.0.3</HangfireMySqlStoragePackageVersion> |
|||
<HangfireMSSQLStoragePackageVersion>1.8.2</HangfireMSSQLStoragePackageVersion> |
|||
<NESTPackageVersion>7.15.1</NESTPackageVersion> |
|||
<NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion> |
|||
<OpenTelemetryExtensionsHostingPackageVersion>1.0.0-rc8</OpenTelemetryExtensionsHostingPackageVersion> |
|||
<OpenTelemetryExporterZipkinPackageVersion>1.3.1</OpenTelemetryExporterZipkinPackageVersion> |
|||
<OpenTelemetryInstrumentationAspNetCorePackageVersion>1.0.0-rc8</OpenTelemetryInstrumentationAspNetCorePackageVersion> |
|||
<OpenTelemetryInstrumentationHttpPackageVersion>1.0.0-rc8</OpenTelemetryInstrumentationHttpPackageVersion> |
|||
<OpenTelemetryContribInstrumentationEntityFrameworkCorePackageVersion>1.0.0-beta2</OpenTelemetryContribInstrumentationEntityFrameworkCorePackageVersion> |
|||
<SerilogPackageVersion>2.10.0</SerilogPackageVersion> |
|||
<SerilogSinksAsyncPackageVersion>1.5.0</SerilogSinksAsyncPackageVersion> |
|||
<SerilogAspNetCorePackageVersion>5.0.0</SerilogAspNetCorePackageVersion> |
|||
<QuartzNETPackageVersion>3.3.3</QuartzNETPackageVersion> |
|||
<StackExchangeRedisPackageVersion>2.2.4</StackExchangeRedisPackageVersion> |
|||
<SerilogPackageVersion>2.12.0</SerilogPackageVersion> |
|||
<SerilogAspNetCorePackageVersion>7.0.0</SerilogAspNetCorePackageVersion> |
|||
<SerilogEnrichersEnvironmentPackageVersion>2.2.0</SerilogEnrichersEnvironmentPackageVersion> |
|||
<SerilogEnrichersAssemblyPackageVersion>2.0.0</SerilogEnrichersAssemblyPackageVersion> |
|||
<SerilogEnrichersProcessPackageVersion>2.0.1</SerilogEnrichersProcessPackageVersion> |
|||
<SerilogEnrichersProcessPackageVersion>2.0.2</SerilogEnrichersProcessPackageVersion> |
|||
<SerilogEnrichersThreadPackageVersion>3.1.0</SerilogEnrichersThreadPackageVersion> |
|||
<SerilogExtensionsLoggingPackageVersion>3.0.1</SerilogExtensionsLoggingPackageVersion> |
|||
<SerilogSettingsConfigurationPackageVersion>3.4.0</SerilogSettingsConfigurationPackageVersion> |
|||
<SerilogSettingsConfigurationPackageVersion>7.0.1</SerilogSettingsConfigurationPackageVersion> |
|||
<SerilogSinksConsolePackageVersion>4.0.0</SerilogSinksConsolePackageVersion> |
|||
<SerilogSinksElasticsearchPackageVersion>8.4.1</SerilogSinksElasticsearchPackageVersion> |
|||
<SerilogSinksElasticsearchPackageVersion>9.0.3</SerilogSinksElasticsearchPackageVersion> |
|||
<SerilogSinksFilePackageVersion>5.0.0</SerilogSinksFilePackageVersion> |
|||
<SwashbuckleAspNetCorePackageVersion>6.1.5</SwashbuckleAspNetCorePackageVersion> |
|||
<SwashbuckleAspNetCorePackageVersion>6.3.0</SwashbuckleAspNetCorePackageVersion> |
|||
<PollyPackageVersion>7.2.3</PollyPackageVersion> |
|||
<MicrosoftPackageVersion>7.0.*</MicrosoftPackageVersion> |
|||
<MicrosoftEntityFrameworkCorePackageVersion>7.0.2</MicrosoftEntityFrameworkCorePackageVersion> |
|||
<XunitTestPackageVersion>2.4.1</XunitTestPackageVersion> |
|||
<ShouldlyPackageVersion>3.0.2</ShouldlyPackageVersion> |
|||
<NSubstitutePackageVersion>4.2.1</NSubstitutePackageVersion> |
|||
<MicrosoftNETTestSdkPackageVersion>17.3.2</MicrosoftNETTestSdkPackageVersion> |
|||
<XunitPackageVersion>2.5.0</XunitPackageVersion> |
|||
<CoverletCollectorPackageVersion>3.0.2</CoverletCollectorPackageVersion> |
|||
<NSubstitutePackageVersion>4.2.1</NSubstitutePackageVersion> |
|||
<ShouldlyPackageVersion>3.0.2</ShouldlyPackageVersion> |
|||
</PropertyGroup> |
|||
</Project> |
|||
Loading…
Reference in new issue