文件上传功能优化

This commit is contained in:
陈淳
2022-10-12 14:43:35 +08:00
parent 4a54eb56a7
commit dd7bbb138a
72 changed files with 104 additions and 68 deletions

View File

@@ -116,7 +116,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers
//落盘文件文件名为雪花id+自己的扩展名
string filename = data.Id.ToString() + Path.GetExtension(f.FileName);
using (var stream = new FileStream(Path.Combine($"{PathConst.wwwroot}/{type}", filename), FileMode.CreateNew, FileAccess.Write))
string typePath = $"{PathConst.wwwroot}/{type}";
if (!Directory.Exists(typePath))
{
Directory.CreateDirectory(typePath);
}
using (var stream = new FileStream(Path.Combine(typePath, filename), FileMode.CreateNew, FileAccess.Write))
{
await f.CopyToAsync(stream);
}