parent
05daabf32a
commit
026782caa5
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue