Browse Source

上传文件从腾讯云换到阿里云

ingredientmanage
gwbvipvip 7 months ago
parent
commit
8ef177a037
11 changed files with 125 additions and 2 deletions
  1. +1
    -0
      BPA.SAAS.Manage.Application/BPA.SAAS.Manage.Application.csproj
  2. +27
    -0
      BPA.SAAS.Manage.Application/System/AliyunOssServices.cs
  3. +24
    -0
      BPA.SAAS.Manage.Application/System/Dtos/AliyunDto.cs
  4. +15
    -0
      BPA.SAAS.Manage.Application/System/Interface/IAliyunOssService.cs
  5. +31
    -0
      BPA.SAAS.Manage.Application/System/Services/AliyunOssService.cs
  6. +1
    -0
      BPA.SAAS.Manage.Comm/BPA.SAAS.Manage.Comm.csproj
  7. +1
    -0
      BPA.SAAS.Manage.Core/BPA.SAAS.Manage.Core.csproj
  8. +1
    -0
      BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj
  9. +9
    -2
      BPA.SAAS.Manage.Web.Core/Startup.cs
  10. +1
    -0
      BPA.SAAS.Manage.Web.Entry/BPA.SAAS.Manage.Web.Entry.csproj
  11. +14
    -0
      BPA.SAAS.Manage.Web.Entry/appsettings.json

+ 1
- 0
BPA.SAAS.Manage.Application/BPA.SAAS.Manage.Application.csproj View File

@@ -22,6 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" />
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.35" />
</ItemGroup>



+ 27
- 0
BPA.SAAS.Manage.Application/System/AliyunOssServices.cs View File

@@ -0,0 +1,27 @@
using BPA.Aliyun.OSS.Options;
using BPA.SAAS.Manage.Application.System.Dtos;
using BPA.SAAS.Manage.Application.System.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.System
{
[ApiDescriptionSettings("SYS", Tag = "获取阿里云参数")]
public class AliyunOssServices : ITransient, IDynamicApiController
{
IAliyunOssService _aliyunOssService;
public AliyunOssServices(IAliyunOssService aliyunOssService)
{
_aliyunOssService = aliyunOssService;
}

[HttpPost("/api/systemconfig/GeneratePostPolicy"), ApiDescriptionSettings(SplitCamelCase = false), AllowAnonymous, NonUnify]
public async Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request)
{
return await _aliyunOssService.GeneratePostPolicyAsync(request);
}
}
}

+ 24
- 0
BPA.SAAS.Manage.Application/System/Dtos/AliyunDto.cs View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.System.Dtos
{
public class Aliyun0ssGeneratePostPolicyRequest
{
/// <summary>
/// 根目录
/// </summary>
[DisplayName("根目录")]
[Required(ErrorMessage = "[{0}]不能为空")]
public string Directory { get; set; }

/// <summary>
/// 是否构建唯一目录
/// </summary>
public bool BuildUniqueDirectory { get; set; }
}
}

+ 15
- 0
BPA.SAAS.Manage.Application/System/Interface/IAliyunOssService.cs View File

@@ -0,0 +1,15 @@
using BPA.Aliyun.OSS.Options;
using BPA.SAAS.Manage.Application.System.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.System.Interface
{
public interface IAliyunOssService
{
Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request);
}
}

+ 31
- 0
BPA.SAAS.Manage.Application/System/Services/AliyunOssService.cs View File

@@ -0,0 +1,31 @@
using BPA.Aliyun.OSS;
using BPA.Aliyun.OSS.Options;
using BPA.SAAS.Manage.Application.System.Dtos;
using BPA.SAAS.Manage.Application.System.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.System.Services
{
public class AliyunOssService : IAliyunOssService, ITransient
{
private readonly ISqlSugarClient _db;
private AliyunOssClient _aliyunOssClient;
public AliyunOssService(ISqlSugarClient db, AliyunOssClient aliyunOssClient)
{
_db = db;
_aliyunOssClient = aliyunOssClient;
}

public async Task<AliyunOssPostPolicyResponse> GeneratePostPolicyAsync(Aliyun0ssGeneratePostPolicyRequest request)
{
var dir = request.Directory;
dir = !dir.EndsWith("/") ? dir + "/" : dir;
var data = await _aliyunOssClient.GeneratePostPolicyAsync(dir);
return data;
}
}
}

+ 1
- 0
BPA.SAAS.Manage.Comm/BPA.SAAS.Manage.Comm.csproj View File

@@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" />
<PackageReference Include="Furion.Pure" Version="4.9.1.20" />
<PackageReference Include="Npoi.Mapper" Version="6.2.1" />
</ItemGroup>


+ 1
- 0
BPA.SAAS.Manage.Core/BPA.SAAS.Manage.Core.csproj View File

@@ -14,6 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.8.5" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.8.5" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />


+ 1
- 0
BPA.SAAS.Manage.Web.Core/BPA.SAAS.Manage.Web.Core.csproj View File

@@ -16,6 +16,7 @@


<ItemGroup>
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" />
<PackageReference Include="BPA.MQTTClient" Version="1.0.11" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
</ItemGroup>


+ 9
- 2
BPA.SAAS.Manage.Web.Core/Startup.cs View File

@@ -1,10 +1,12 @@
using BPA.MQTTClient;
using BPA.Aliyun.OSS;
using BPA.MQTTClient;
using BPA.SAAS.Manage.Application.System.Dtos;
using BPA.SAAS.Manage.Core;
using FluentValidation.AspNetCore;
using Furion;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MQTTnet.Client.Connecting;
@@ -70,6 +72,11 @@ namespace BPA.SAAS.Manage.Web.Core
services.AddControllers()
.AddInjectWithUnifyResult();
services.AddMvcFilter<RequestAuditFiltercs>();
services.AddAliyunOss(op =>
{
App.Configuration.Bind("BPA:Aliyun:Oss", op);
});

}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
@@ -78,7 +85,7 @@ namespace BPA.SAAS.Manage.Web.Core
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();

app.UseRouting();


+ 1
- 0
BPA.SAAS.Manage.Web.Entry/BPA.SAAS.Manage.Web.Entry.csproj View File

@@ -12,6 +12,7 @@


<ItemGroup>
<PackageReference Include="BPA.Aliyun.OSS" Version="1.0.7" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>



+ 14
- 0
BPA.SAAS.Manage.Web.Entry/appsettings.json View File

@@ -31,6 +31,20 @@
"UserName": "emqx_u_block",
"Password": "emqx_p_admin8765490789"
},
"BPA": {
"Aliyun": {
"Oss": {
"AccessKeyId": "LTAI5tGkcsA6HmUL2EyNfYmq",
"AccessKeySecret": "gPCBqVHqnq17f2YikwdtsjExl1NRVF",
"Endpoint": "https://oss-cn-chengdu.aliyuncs.com",
"BucketName": "bpa", //"erphk",
"PresignedUriExpirationMinutes": 1440,
"PolicyExpirationMinutes": 1440,
"ProjectName": "hkerp",
"ServiceName": "test"
}
}
},
"order_url": "http://order",
"wechat_url": "http://wechat"
}

Loading…
Cancel
Save