1. 添加回传文件大小

2. bugfix: 部分字段更新空值
feature-flyModify
陈伟 2025-07-25 10:06:58 +08:00
parent 05daabf32a
commit 026782caa5
2 changed files with 13 additions and 8 deletions

View File

@ -19,7 +19,6 @@ using SixLabors.ImageSharp.Processing;
using SqlSugar; using SqlSugar;
namespace OpenAuth.App.BaseApp.Subscribe; namespace OpenAuth.App.BaseApp.Subscribe;
public class ConfigSubscribe : IJob public class ConfigSubscribe : IJob
@ -272,9 +271,9 @@ public class ConfigSubscribe : IJob
var imageStream = _minioService.GetObjectAsStream("", objectKey1); var imageStream = _minioService.GetObjectAsStream("", objectKey1);
var width = 0; var width = 0;
var height = 0; var height = 0;
var size = 0L;
using (var image = Image.Load(imageStream.Result)) using (var image = Image.Load(imageStream.Result))
{ {
width = image.Width; width = image.Width;
height = image.Height; height = image.Height;
var thumbnailSize = 100; // 缩略图大小,可以根据需要调整 var thumbnailSize = 100; // 缩略图大小,可以根据需要调整
@ -287,13 +286,16 @@ public class ConfigSubscribe : IJob
// 将缩略图保存到内存流中(为了上传) // 将缩略图保存到内存流中(为了上传)
using (var memoryStream = new MemoryStream()) using (var memoryStream = new MemoryStream())
{ {
size = memoryStream.Length;
thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式如Png, Bmp等。 thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式如Png, Bmp等。
memoryStream.Position = 0; // 重置流的位置到开始处 memoryStream.Position = 0; // 重置流的位置到开始处
// 上传缩略图到MinIO // 上传缩略图到MinIO
await _minioService.PutObjectAsync("", data.file.name.ToString(), suoluokey, memoryStream); // 根据实际格式修改Content-Type await _minioService.PutObjectAsync("", data.file.name.ToString(), suoluokey,
memoryStream); // 根据实际格式修改Content-Type
} }
} }
var fileUpload = new LasaMediaFile() var fileUpload = new LasaMediaFile()
{ {
Id = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(),
@ -319,7 +321,10 @@ public class ConfigSubscribe : IJob
FlightType = flightType, FlightType = flightType,
Width = width, Width = width,
Height = height, Height = height,
minipic = suoluokey minipic = suoluokey,
Size = size,
ShowOnMap = 1,
display = 1
}; };
// todo 添加事务 // todo 添加事务
await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync(); await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();

View File

@ -106,7 +106,7 @@ public class LasaMediaFile
public string FileTags { get; set; } public string FileTags { get; set; }
public int Size { get; set; } public long Size { get; set; }
public int Width { get; set; } public int Width { get; set; }
public int Height { get; set; } public int Height { get; set; }
public string Tid { get; set; } public string Tid { get; set; }