parent
05daabf32a
commit
026782caa5
|
|
@ -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
|
||||||
|
|
@ -269,14 +268,14 @@ public class ConfigSubscribe : IJob
|
||||||
string objectKey1 = data.file.object_key.ToString();
|
string objectKey1 = data.file.object_key.ToString();
|
||||||
string suoluokey = "minipic/" + data.file.name.ToString();
|
string suoluokey = "minipic/" + data.file.name.ToString();
|
||||||
//缩略图处理
|
//缩略图处理
|
||||||
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; // 缩略图大小,可以根据需要调整
|
||||||
var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions
|
var thumbnail = image.Clone(ctx => ctx.Resize(new ResizeOptions
|
||||||
{
|
{
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue