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) {