From f2dd586660d812214e4f53271678e5ba7e3a2cd8 Mon Sep 17 00:00:00 2001 From: yzp Date: Wed, 16 Jul 2025 09:31:20 +0800 Subject: [PATCH] =?UTF-8?q?BUG=EF=BC=9A=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs b/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs index 3bfb7780..95c6eaed 100644 --- a/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs +++ b/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs @@ -43,7 +43,7 @@ public class SysFileService : IDynamicApiController, ITransient { _customFileProvider = _namedServiceProvider.GetService(nameof(SSHFileProvider)); } - else if (App.Configuration["Upload:EnableSaveFileToDb"].ToBoolean()) + else if (_uploadOptions.EnableSaveDb) { _customFileProvider = _namedServiceProvider.GetService(nameof(DbFileProvider)); } @@ -138,6 +138,7 @@ public class SysFileService : IDynamicApiController, ITransient /// [HttpGet("/upload/downloadfile")] [DisplayName("根据文件Id和MD5下载")] + [AllowAnonymous] public async Task DownloadFile2([FromQuery] long id, [FromQuery] string fileMd5) { var file = await GetFile(id); @@ -272,7 +273,10 @@ public class SysFileService : IDynamicApiController, ITransient // 不管要不要验证md5,也把Md6计算出来,方便统计重复的文件。 await using (var fileStream = input.File.OpenReadStream()) { - fileMd5 = OssUtils.ComputeContentMd5(fileStream, fileStream.Length); + //fileMd5 = OssUtils.ComputeContentMd5(fileStream, fileStream.Length); // 这种返回的是base64字符串有"="这种特殊字符,格式不规范 + byte[] bsFile = new byte[fileStream.Length]; + _ = fileStream.Read(bsFile, 0, bsFile.Length); + fileMd5 = MD5Encryption.Encrypt(bsFile);// 使用这个返回长度为32的固定字符串 } if (_uploadOptions.EnableMd5) {