Merge remote-tracking branch 'origin/main'
commit
6681a3c31c
|
|
@ -6,6 +6,7 @@ using Minio;
|
|||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
using System.IO;
|
||||
|
||||
namespace Infrastructure.CloudSdk.minio;
|
||||
|
||||
|
|
@ -241,4 +242,45 @@ public class MinioService
|
|||
var url = await _minioClient.PresignedGetObjectAsync(args);
|
||||
return url;
|
||||
}
|
||||
|
||||
public async Task PutObjectAsync(string buketName,string tupianName,string objectName,MemoryStream memory) {
|
||||
|
||||
if (string.IsNullOrEmpty(buketName))
|
||||
{
|
||||
buketName = _bucketName;
|
||||
}
|
||||
PutObjectArgs args = new PutObjectArgs();
|
||||
args.WithBucket(buketName).WithObject(objectName).WithStreamData(memory).WithObjectSize(memory.Length).WithContentType("image/jpeg");
|
||||
|
||||
await _minioClient.PutObjectAsync(args);
|
||||
|
||||
}
|
||||
public async Task<Stream> GetObjectAsStream(string bucketName, string objectName)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(bucketName))
|
||||
{
|
||||
bucketName = _bucketName;
|
||||
}
|
||||
var memoryStream = new MemoryStream();
|
||||
try
|
||||
{
|
||||
await _minioClient.GetObjectAsync(new GetObjectArgs()
|
||||
.WithBucket(bucketName)
|
||||
.WithObject(objectName)
|
||||
.WithCallbackStream(stream =>
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
}));
|
||||
|
||||
memoryStream.Position = 0; // 重置流位置
|
||||
return memoryStream;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Error getting object: {e.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -14,8 +14,12 @@ using OpenAuth.App.ServiceApp;
|
|||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.WebApi;
|
||||
using Quartz;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
|
||||
namespace OpenAuth.App.BaseApp.Subscribe;
|
||||
|
||||
public class ConfigSubscribe : IJob
|
||||
|
|
@ -262,6 +266,34 @@ public class ConfigSubscribe : IJob
|
|||
.Where(a => a.ObjectKey.Equals(objectKey)).SingleAsync();
|
||||
if (mediaFile == null)
|
||||
{
|
||||
string objectKey1 = data.file.object_key.ToString();
|
||||
string suoluokey = "minipic/" + data.file.name.ToString();
|
||||
//缩略图处理
|
||||
var imageStream = _minioService.GetObjectAsStream("", objectKey1);
|
||||
var width = 0;
|
||||
var height = 0;
|
||||
using (var image = Image.Load(imageStream.Result))
|
||||
{
|
||||
|
||||
width = image.Width;
|
||||
height = image.Height;
|
||||
var thumbnailSize = 100; // 缩略图大小,可以根据需要调整
|
||||
var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions
|
||||
{
|
||||
Size = new Size(thumbnailSize, thumbnailSize),
|
||||
Mode = ResizeMode.Crop // 根据需要选择裁剪或填充模式
|
||||
}));
|
||||
|
||||
// 将缩略图保存到内存流中(为了上传)
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式,如Png, Bmp等。
|
||||
memoryStream.Position = 0; // 重置流的位置到开始处
|
||||
|
||||
// 上传缩略图到MinIO
|
||||
await _minioService.PutObjectAsync("", data.file.name.ToString(), suoluokey, memoryStream); // 根据实际格式修改Content-Type
|
||||
}
|
||||
}
|
||||
var fileUpload = new LasaMediaFile()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
|
|
@ -284,7 +316,10 @@ public class ConfigSubscribe : IJob
|
|||
ParentKey = folderKey[2],
|
||||
Tid = result.tid,
|
||||
Bid = result.bid,
|
||||
FlightType = flightType
|
||||
FlightType = flightType,
|
||||
Width = width,
|
||||
Height = height,
|
||||
minipic = suoluokey
|
||||
};
|
||||
// todo 添加事务
|
||||
await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();
|
||||
|
|
|
|||
|
|
@ -116,4 +116,6 @@ public class LasaMediaFile
|
|||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string PicLink { get; set; }
|
||||
|
||||
public string minipic { get; set; }
|
||||
}
|
||||
|
|
@ -13,6 +13,12 @@ using StackExchange.Redis;
|
|||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Minio;
|
||||
using Infrastructure.CloudSdk.minio;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
||||
{
|
||||
|
|
@ -27,13 +33,17 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
private readonly MqttClientManager _mqttClientManager;
|
||||
private readonly MqttMessageCenter _mqttCenter;
|
||||
private readonly RedisCacheContext _cache;
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly MinioService _minioService;
|
||||
|
||||
public AirportMaintenanceController(AirportMaintenanceApp app, MqttClientManager mqttClientManager, MqttMessageCenter mqttCenter, RedisCacheContext cache)
|
||||
public AirportMaintenanceController(AirportMaintenanceApp app, MqttClientManager mqttClientManager, MqttMessageCenter mqttCenter, RedisCacheContext cache, HttpClient httpClient,MinioService minioService)
|
||||
{
|
||||
_app = app;
|
||||
_mqttClientManager = mqttClientManager;
|
||||
_mqttCenter = mqttCenter;
|
||||
_cache = cache;
|
||||
_httpClient = httpClient;
|
||||
_minioService = minioService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 机场注册 注册码生成
|
||||
|
|
@ -745,6 +755,45 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
}
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<string>> getMiniPic()
|
||||
{
|
||||
var result = new Response<string>();
|
||||
try
|
||||
{
|
||||
// string presignedUrl = "http://175.27.168.120:6014/test/44fc8b4b-9448-4e79-a71d-536d094b8598/ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_202507231000_002_ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_20250723100110_0001_V.jpeg";
|
||||
var imageStream = _minioService.GetObjectAsStream("test", "44fc8b4b-9448-4e79-a71d-536d094b8598/ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_202507231000_002_ad854032-d4b7-42dc-8ac0-d1faef0ebc1e/DJI_20250723100110_0001_V.jpeg");
|
||||
// var imageStream = await _httpClient.GetStreamAsync(presignedUrl);
|
||||
|
||||
using (var image = Image.Load(imageStream.Result))
|
||||
{
|
||||
var width = image.Width;
|
||||
var height = image.Height;
|
||||
var thumbnailSize = 100; // 缩略图大小,可以根据需要调整
|
||||
var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions
|
||||
{
|
||||
Size = new Size(thumbnailSize, thumbnailSize),
|
||||
Mode = ResizeMode.Crop // 根据需要选择裁剪或填充模式
|
||||
}));
|
||||
|
||||
// 将缩略图保存到内存流中(为了上传)
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式,如Png, Bmp等。
|
||||
memoryStream.Position = 0; // 重置流的位置到开始处
|
||||
|
||||
// 上传缩略图到MinIO
|
||||
await _minioService.PutObjectAsync("test" , "suolue_DJI_20250723100110_0001_V.jpeg", "abc/suolue_DJI_20250723100110_0001_V.jpeg", memoryStream); // 根据实际格式修改Content-Type
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
var bindStatusList = snList?.Select(sn => new
|
||||
{
|
||||
device_callsign = "sdhc",
|
||||
is_device_bind_organization = true,
|
||||
is_device_bind_organization = false,
|
||||
organization_id = "371300",
|
||||
organization_name = "sdhc",
|
||||
sn = sn
|
||||
|
|
@ -179,7 +179,7 @@ namespace OpenAuth.WebApi.Model.mqtt
|
|||
}
|
||||
}
|
||||
}
|
||||
uavsn = uavsn == "" ? "1581F8HGX254V00A0BUY" : uavsn;
|
||||
uavsn = uavsn == "" ? "01" : uavsn;
|
||||
_manageApp.AddDronePort(lasaDronePort);
|
||||
_manageApp.AddLasaUav(lasaUav);
|
||||
var topics = new List<string>();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="b3527dbf-bcaa-414f-a2ff-418cfa5cd713" version="1">
|
||||
<creationDate>2025-07-24T06:13:21.826273Z</creationDate>
|
||||
<activationDate>2025-07-24T06:13:21.7975161Z</activationDate>
|
||||
<expirationDate>2025-10-22T06:13:21.7975161Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>020bLK2hMAxhtpFFNizORt/y5XGIzePkwQspd4UzuNPItcuu8v3ndDKcS8dxxU0v6z915v2Lw6RlW1Esro33Ew==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
Loading…
Reference in New Issue