|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|