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;
namespace OpenAuth.App.BaseApp.Subscribe;
public class ConfigSubscribe : IJob
@ -269,14 +268,14 @@ public class ConfigSubscribe : IJob
string objectKey1 = data.file.object_key.ToString();
string suoluokey = "minipic/" + data.file.name.ToString();
//缩略图处理
var imageStream = _minioService.GetObjectAsStream("", objectKey1);
var imageStream = _minioService.GetObjectAsStream("", objectKey1);
var width = 0;
var height = 0;
var size = 0L;
using (var image = Image.Load(imageStream.Result))
{
width = image.Width;
height = image.Height;
width = image.Width;
height = image.Height;
var thumbnailSize = 100; // 缩略图大小,可以根据需要调整
var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions
{
@ -287,13 +286,16 @@ public class ConfigSubscribe : IJob
// 将缩略图保存到内存流中(为了上传)
using (var memoryStream = new MemoryStream())
{
size = memoryStream.Length;
thumbnail.SaveAsJpeg(memoryStream); // 可以根据需要选择不同的格式如Png, Bmp等。
memoryStream.Position = 0; // 重置流的位置到开始处
// 上传缩略图到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()
{
Id = Guid.NewGuid().ToString(),
@ -319,7 +321,10 @@ public class ConfigSubscribe : IJob
FlightType = flightType,
Width = width,
Height = height,
minipic = suoluokey
minipic = suoluokey,
Size = size,
ShowOnMap = 1,
display = 1
};
// todo 添加事务
await _sqlSugarClient.Insertable(fileUpload).ExecuteCommandAsync();

View File

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