同步代码

main
陈伟 1 month ago
parent 180b879248
commit 20ea54645d

@ -1,11 +1,12 @@
using System.Dynamic;
using System.Net;
using System.Net.Http.Headers;
using System.Text;
using Infrastructure.Cache;
using Infrastructure.CloudSdk;
using Infrastructure.CloudSdk.minio;
using Infrastructure.CloudSdk.wayline;
using Infrastructure.Extensions;
using Irony.Parsing.Construction;
using MetadataExtractor;
using MetadataExtractor.Formats.Exif;
using Microsoft.Extensions.Logging;
@ -15,8 +16,6 @@ using OpenAuth.App.ServiceApp;
using OpenAuth.Repository.Domain;
using OpenAuth.WebApi;
using Quartz;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SqlSugar;
namespace OpenAuth.App.BaseApp.Subscribe;
@ -283,12 +282,12 @@ public class ConfigSubscribe : IJob
// 目前读取64KB
// 添加Range请求头
httpClient.DefaultRequestHeaders.Range =
new System.Net.Http.Headers.RangeHeaderValue(0, 65535);
new RangeHeaderValue(0, 65535);
try
{
var response = httpClient
.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead).Result;
if (response.StatusCode == System.Net.HttpStatusCode.PartialContent)
if (response.StatusCode == HttpStatusCode.PartialContent)
{
//Focal Length 35: 24 mm
//Exif Image Width: 4032 pixels : Exif SubIFD
@ -372,7 +371,7 @@ public class ConfigSubscribe : IJob
await _minioService.PutObjectAsync("", data.file.name.ToString(), suoluokey,
new MemoryStream(buffer));
}
else if (response.StatusCode == System.Net.HttpStatusCode.OK)
else if (response.StatusCode == HttpStatusCode.OK)
{
// 服务器不支持Range请求返回完整内容
throw new InvalidOperationException("服务器不支持Range请求");
@ -388,37 +387,6 @@ public class ConfigSubscribe : IJob
}
}
}
/*string objectKey1 = data.file.object_key.ToString();
//缩略图处理
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;
//size = imageStream.Result.Length;
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("", data.file.name.ToString(), suoluokey,
memoryStream); // 根据实际格式修改Content-Type
}
}*/
var fileUpload = new LasaMediaFile()
{
Id = Guid.NewGuid().ToString(),

@ -1,5 +1,8 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.Net;
using System.Net.Http.Headers;
using System.Text;
using Infrastructure.CloudSdk.minio;
using Infrastructure.CloudSdk.wayline;
using Infrastructure.Extensions;
@ -179,7 +182,7 @@ public class TestAbc
static string GetPropertyName(int id)
{
// 常见的EXIF属性ID映射
var propertyNames = new System.Collections.Generic.Dictionary<int, string>
var propertyNames = new Dictionary<int, string>
{
{ 0x010F, "制造商" },
{ 0x0110, "相机型号" },
@ -213,7 +216,7 @@ public class TestAbc
case 1: // 字节型
return BitConverter.ToString(prop.Value);
case 2: // 字符串
return System.Text.Encoding.ASCII.GetString(prop.Value).Trim('\0');
return Encoding.ASCII.GetString(prop.Value).Trim('\0');
case 3: // 16位整数
return BitConverter.ToInt16(prop.Value, 0).ToString();
case 4: // 32位整数
@ -428,20 +431,21 @@ public class TestAbc
long? picSize = 0;
int width = 0, height = 0, focalLength = 0;
int offset = 0, length = 0;
string model = "";
using (var httpClient = new HttpClient())
{
var total = 0L;
// 添加Range请求头
httpClient.DefaultRequestHeaders.Range = new System.Net.Http.Headers.RangeHeaderValue(0, 65535);
httpClient.DefaultRequestHeaders.Range = new RangeHeaderValue(0, 65535);
try
{
var response = httpClient
.GetAsync(
"http://" + minio.endPoint + "/" + minio._bucketName + "/" +
"/640aea27-2dd3-4081-933c-fcef432fcec0/71924889-540d-4362-aeb1-9ee787a655a7/DJI_202508050906_002_71924889-540d-4362-aeb1-9ee787a655a7/DJI_20250805090809_0001_V.jpeg",
"f4ac965b-b5bb-44ce-83e6-10d5758c4960/8529f6f0-2fc2-4357-95a4-9244fae06e9e/DJI_202508081026_002_8529f6f0-2fc2-4357-95a4-9244fae06e9e/DJI_20250808102710_0002_D.NAV",
HttpCompletionOption.ResponseHeadersRead).Result;
if (response.StatusCode == System.Net.HttpStatusCode.PartialContent)
if (response.StatusCode == HttpStatusCode.PartialContent)
{
//Focal Length 35: 24 mm
//Exif Image Width: 4032 pixels : Exif SubIFD
@ -491,6 +495,17 @@ public class TestAbc
}
}
if (directory.Name.Equals("Exif IFD0"))
{
foreach (var tag in directory.Tags)
{
if (tag.Name.Equals("Model"))
{
model = tag.Description;
}
}
}
//Console.WriteLine(directory.Name);
if (directory.Name.Equals("Exif Thumbnail"))
{
@ -519,7 +534,8 @@ public class TestAbc
Size = picSize,
ShowOnMap = 1,
display = 1,
FocalLength = focalLength
FocalLength = focalLength,
PayloadModelKey = model,
};
Console.WriteLine("是否有错呢:" + JsonConvert.SerializeObject(fileUpload));
ms.Seek(offset + 6, SeekOrigin.Begin);
@ -530,7 +546,7 @@ public class TestAbc
Console.WriteLine("读取的字节长度: " + bytesRead);
File.WriteAllBytes("f:/abbbbbb.jpeg", buffer);
}
else if (response.StatusCode == System.Net.HttpStatusCode.OK)
else if (response.StatusCode == HttpStatusCode.OK)
{
// 服务器不支持Range请求返回完整内容
throw new InvalidOperationException("服务器不支持Range请求");

Loading…
Cancel
Save