BUG:文件上传
This commit is contained in:
parent
79f4b19ba7
commit
f2dd586660
@ -43,7 +43,7 @@ public class SysFileService : IDynamicApiController, ITransient
|
||||
{
|
||||
_customFileProvider = _namedServiceProvider.GetService<ITransient>(nameof(SSHFileProvider));
|
||||
}
|
||||
else if (App.Configuration["Upload:EnableSaveFileToDb"].ToBoolean())
|
||||
else if (_uploadOptions.EnableSaveDb)
|
||||
{
|
||||
_customFileProvider = _namedServiceProvider.GetService<ITransient>(nameof(DbFileProvider));
|
||||
}
|
||||
@ -138,6 +138,7 @@ public class SysFileService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
[HttpGet("/upload/downloadfile")]
|
||||
[DisplayName("根据文件Id和MD5下载")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> 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)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user