Browse Source

优化上传

zhontai 2 năm trước cách đây
mục cha
commit
41587de664

+ 2 - 2
src/platform/ZhonTai.Admin/Core/Helpers/UploadHelper.cs

@@ -27,7 +27,7 @@ public class UploadHelper
     /// <param name="args"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    public static async Task<FileInfo> UploadAsync(IFormFile file, FileUploadConfig config, object args, CancellationToken cancellationToken = default)
+    public async Task<FileInfo> UploadAsync(IFormFile file, FileUploadConfig config, object args, CancellationToken cancellationToken = default)
     { 
         if (file == null || file.Length < 1)
         {
@@ -75,7 +75,7 @@ public class UploadHelper
     /// <param name="filePath"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    public static async Task SaveAsync(IFormFile file, string filePath, CancellationToken cancellationToken = default)
+    public async Task SaveAsync(IFormFile file, string filePath, CancellationToken cancellationToken = default)
     {
         using var stream = File.Create(filePath);
         await file.CopyToAsync(stream, cancellationToken);

+ 1 - 1
src/platform/ZhonTai.Admin/Services/Document/DocumentService.cs

@@ -248,7 +248,7 @@ public class DocumentService : BaseService, IDocumentService, IDynamicApi
         var uploadHelper = LazyGetRequiredService<UploadHelper>();
 
         var config = uploadConfig.Document;
-        var fileInfo = await UploadHelper.UploadAsync(input.File, config, new { input.Id });
+        var fileInfo = await uploadHelper.UploadAsync(input.File, config, new { input.Id });
         //保存文档图片
         await AddImageAsync(new DocumentAddImageInput
         {

+ 1 - 1
src/platform/ZhonTai.Admin/Services/User/UserService.cs

@@ -697,7 +697,7 @@ public class UserService : BaseService, IUserService, IDynamicApi
         var uploadConfig = LazyGetRequiredService<IOptionsMonitor<UploadConfig>>().CurrentValue;
         var uploadHelper = LazyGetRequiredService<UploadHelper>();
         var config = uploadConfig.Avatar;
-        var fileInfo = await UploadHelper.UploadAsync(file, config, new { User.Id });
+        var fileInfo = await uploadHelper.UploadAsync(file, config, new { User.Id });
         return fileInfo.FileRelativePath;
     }
 }