From 213a9a5555b688dc13bea527a029817da4871db2 Mon Sep 17 00:00:00 2001 From: hans Date: Sun, 9 Feb 2025 09:37:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=B9=89ICustomFileProvider=EF=BC=88?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=96=87=E4=BB=B6=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E5=99=A8=E6=8E=A5=E5=8F=A3=EF=BC=89=EF=BC=8C=E5=88=86=E5=88=AB?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0SSH=E5=92=8COSS=EF=BC=8C=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9C=8D=E5=8A=A1=E4=BB=A3=E7=A0=81=E8=80=A6?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../File/FileProvider/DefaultFileProvider.cs | 59 +++++++ .../File/FileProvider/ICustomFileProvider.cs | 42 +++++ .../File/FileProvider/OSSFileProvider.cs | 78 +++++++++ .../File/FileProvider/SSHFileProvider.cs | 44 +++++ .../Service/File/SysFileService.cs | 153 +++--------------- 5 files changed, 244 insertions(+), 132 deletions(-) create mode 100644 Admin.NET/Admin.NET.Core/Service/File/FileProvider/DefaultFileProvider.cs create mode 100644 Admin.NET/Admin.NET.Core/Service/File/FileProvider/ICustomFileProvider.cs create mode 100644 Admin.NET/Admin.NET.Core/Service/File/FileProvider/OSSFileProvider.cs create mode 100644 Admin.NET/Admin.NET.Core/Service/File/FileProvider/SSHFileProvider.cs diff --git a/Admin.NET/Admin.NET.Core/Service/File/FileProvider/DefaultFileProvider.cs b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/DefaultFileProvider.cs new file mode 100644 index 00000000..3663b80e --- /dev/null +++ b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/DefaultFileProvider.cs @@ -0,0 +1,59 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + + + +namespace Admin.NET.Core.Service; + +public class DefaultFileProvider : ICustomFileProvider, ITransient +{ + public Task DeleteFileAsync(SysFile sysFile) + { + var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, sysFile.FilePath ?? "", sysFile.Id + sysFile.Suffix); + if (File.Exists(filePath)) File.Delete(filePath); + return Task.CompletedTask; + } + + public async Task DownloadFileBase64Async(SysFile sysFile) + { + var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, sysFile.FilePath); + if (!Directory.Exists(filePath)) + Directory.CreateDirectory(filePath); + + var realFile = Path.Combine(filePath, $"{sysFile.Id}{sysFile.Suffix}"); + if (!File.Exists(realFile)) + { + Log.Error($"DownloadFileBase64:文件[{realFile}]不存在"); + throw Oops.Oh($"文件[{sysFile.FilePath}]不存在"); + } + byte[] fileBytes = await File.ReadAllBytesAsync(realFile); + return Convert.ToBase64String(fileBytes); + } + + public Task GetFileStreamResultAsync(SysFile sysFile, string fileName) + { + var filePath = Path.Combine(sysFile.FilePath ?? "", sysFile.Id + sysFile.Suffix); + var path = Path.Combine(App.WebHostEnvironment.WebRootPath, filePath); + return Task.FromResult(new FileStreamResult(new FileStream(path, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName + sysFile.Suffix }); + } + + public async Task UploadFileAsync(IFormFile file, SysFile newFile, string path, string finalName) + { + newFile.Provider = ""; // 本地存储 Provider 显示为空 + var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, path); + if (!Directory.Exists(filePath)) + Directory.CreateDirectory(filePath); + + var realFile = Path.Combine(filePath, finalName); + await using (var stream = File.Create(realFile)) + { + await file.CopyToAsync(stream); + } + + newFile.Url = $"{newFile.FilePath}/{newFile.Id + newFile.Suffix}"; + return newFile; + } +} diff --git a/Admin.NET/Admin.NET.Core/Service/File/FileProvider/ICustomFileProvider.cs b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/ICustomFileProvider.cs new file mode 100644 index 00000000..b6002610 --- /dev/null +++ b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/ICustomFileProvider.cs @@ -0,0 +1,42 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +namespace Admin.NET.Core.Service; + +/// +/// 自定义文件提供器接口 +/// +public interface ICustomFileProvider +{ + /// + /// 获取文件流 + /// + /// + /// + /// + public Task GetFileStreamResultAsync(SysFile sysFile, string fileName); + /// + /// 下载指定文件Base64格式 + /// + /// + /// + public Task DownloadFileBase64Async(SysFile sysFile); + /// + /// 删除文件 + /// + /// + /// + public Task DeleteFileAsync(SysFile sysFile); + /// + /// 上传文件 + /// + /// 文件 + /// + /// 文件存储位置 + /// 文件最终名称 + /// + public Task UploadFileAsync(IFormFile file, SysFile sysFile, string path, string finalName); +} diff --git a/Admin.NET/Admin.NET.Core/Service/File/FileProvider/OSSFileProvider.cs b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/OSSFileProvider.cs new file mode 100644 index 00000000..ba7fe612 --- /dev/null +++ b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/OSSFileProvider.cs @@ -0,0 +1,78 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using OnceMi.AspNetCore.OSS; + +namespace Admin.NET.Core.Service; + +public class OSSFileProvider : ICustomFileProvider,ITransient +{ + private readonly IOSSService _OSSService; + private readonly OSSProviderOptions _OSSProviderOptions; + public OSSFileProvider(IOptions oSSProviderOptions, IOSSServiceFactory ossServiceFactory) { + _OSSProviderOptions = oSSProviderOptions.Value; + if (_OSSProviderOptions.Enabled) + _OSSService = ossServiceFactory.Create(Enum.GetName(_OSSProviderOptions.Provider)); + } + public async Task DeleteFileAsync(SysFile file) + { + await _OSSService.RemoveObjectAsync(file.BucketName, string.Concat(file.FilePath, "/", $"{file.Id}{file.Suffix}")); + } + + public async Task DownloadFileBase64Async(SysFile file) + { + using var httpClient = new HttpClient(); + HttpResponseMessage response = await httpClient.GetAsync(file.Url); + if (response.IsSuccessStatusCode) + { + // 读取文件内容并将其转换为 Base64 字符串 + byte[] fileBytes = await response.Content.ReadAsByteArrayAsync(); + return Convert.ToBase64String(fileBytes); + } + throw new HttpRequestException($"Request failed with status code: {response.StatusCode}"); + } + + public async Task GetFileStreamResultAsync(SysFile file, string fileName) + { + var filePath = Path.Combine(file.FilePath ?? "", file.Id + file.Suffix); + var httpRemoteService = App.GetRequiredService(); + var stream = await httpRemoteService.GetAsStreamAsync(await _OSSService.PresignedGetObjectAsync(file.BucketName, filePath, 5)); + return new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = fileName + file.Suffix }; + } + + public async Task UploadFileAsync(IFormFile file,SysFile sysFile,string path,string finalName) + { + sysFile.Provider = Enum.GetName(_OSSProviderOptions.Provider); + var filePath = string.Concat(path, "/", finalName); + await _OSSService.PutObjectAsync(sysFile.BucketName, filePath, file.OpenReadStream()); + // http://<你的bucket名字>.oss.aliyuncs.com/<你的object名字> + // 生成外链地址 方便前端预览 + switch (_OSSProviderOptions.Provider) + { + case OSSProvider.Aliyun: + sysFile.Url = $"{(_OSSProviderOptions.IsEnableHttps ? "https" : "http")}://{sysFile.BucketName}.{_OSSProviderOptions.Endpoint}/{filePath}"; + break; + + case OSSProvider.QCloud: + var protocol = _OSSProviderOptions.IsEnableHttps ? "https" : "http"; + sysFile.Url = !string.IsNullOrWhiteSpace(_OSSProviderOptions.CustomHost) + ? $"{protocol}://{_OSSProviderOptions.CustomHost}/{filePath}" + : $"{protocol}://{sysFile.BucketName}-{_OSSProviderOptions.Endpoint}.cos.{_OSSProviderOptions.Region}.myqcloud.com/{filePath}"; + break; + + case OSSProvider.Minio: + // 获取Minio文件的下载或者预览地址 + // newFile.Url = await GetMinioPreviewFileUrl(newFile.BucketName, filePath);// 这种方法生成的Url是有7天有效期的,不能这样使用 + // 需要在MinIO中的Buckets开通对 Anonymous 的readonly权限 + var customHost = _OSSProviderOptions.CustomHost; + if (string.IsNullOrWhiteSpace(customHost)) + customHost = _OSSProviderOptions.Endpoint; + sysFile.Url = $"{(_OSSProviderOptions.IsEnableHttps ? "https" : "http")}://{customHost}/{sysFile.BucketName}/{filePath}"; + break; + } + return sysFile; + } +} diff --git a/Admin.NET/Admin.NET.Core/Service/File/FileProvider/SSHFileProvider.cs b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/SSHFileProvider.cs new file mode 100644 index 00000000..f087ca0d --- /dev/null +++ b/Admin.NET/Admin.NET.Core/Service/File/FileProvider/SSHFileProvider.cs @@ -0,0 +1,44 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + + +namespace Admin.NET.Core.Service; + +public class SSHFileProvider : ICustomFileProvider, ITransient +{ + public Task DeleteFileAsync(SysFile sysFile) + { + var fullPath = string.Concat(sysFile.FilePath, "/", sysFile.Id + sysFile.Suffix); + using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], + App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); + helper.DeleteFile(fullPath); + return Task.CompletedTask; + } + + public Task DownloadFileBase64Async(SysFile sysFile) + { + using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], + App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); + return Task.FromResult(Convert.ToBase64String(helper.ReadAllBytes(sysFile.FilePath))); + } + + public Task GetFileStreamResultAsync(SysFile sysFile, string fileName) + { + var filePath = Path.Combine(sysFile.FilePath ?? "", sysFile.Id + sysFile.Suffix); + using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], + App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); + return Task.FromResult( new FileStreamResult(helper.OpenRead(filePath), "application/octet-stream") { FileDownloadName = fileName + sysFile.Suffix }); + } + + public Task UploadFileAsync(IFormFile file, SysFile sysFile, string path, string finalName) + { + var fullPath = string.Concat(path.StartsWith('/') ? path : "/" + path, "/", finalName); + using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], + App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); + helper.UploadFile(file.OpenReadStream(), fullPath); + return Task.FromResult(sysFile); + } +} \ No newline at end of file diff --git a/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs b/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs index a75ae799..cc6efd7c 100644 --- a/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs +++ b/Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs @@ -5,7 +5,6 @@ // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! using Aliyun.OSS.Util; -using OnceMi.AspNetCore.OSS; namespace Admin.NET.Core.Service; @@ -19,21 +18,31 @@ public class SysFileService : IDynamicApiController, ITransient private readonly SqlSugarRepository _sysFileRep; private readonly OSSProviderOptions _OSSProviderOptions; private readonly UploadOptions _uploadOptions; - private readonly IOSSService _OSSService; private readonly string _imageType = ".jpeg.jpg.png.bmp.gif.tif"; + private readonly INamedServiceProvider _namedServiceProvider; + private readonly ICustomFileProvider _customFileProvider; public SysFileService(UserManager userManager, SqlSugarRepository sysFileRep, IOptions oSSProviderOptions, - IOptions uploadOptions, - IOSSServiceFactory ossServiceFactory) + IOptions uploadOptions, INamedServiceProvider namedServiceProvider) { + _namedServiceProvider = namedServiceProvider; _userManager = userManager; _sysFileRep = sysFileRep; _OSSProviderOptions = oSSProviderOptions.Value; _uploadOptions = uploadOptions.Value; if (_OSSProviderOptions.Enabled) - _OSSService = ossServiceFactory.Create(Enum.GetName(_OSSProviderOptions.Provider)); + { + _customFileProvider = _namedServiceProvider.GetService(nameof(OSSFileProvider)); + } + else if (App.Configuration["SSHProvider:Enabled"].ToBoolean()) + { + _customFileProvider = _namedServiceProvider.GetService(nameof(SSHFileProvider)); + } + else { + _customFileProvider = _namedServiceProvider.GetService(nameof(DefaultFileProvider)); + } } /// @@ -135,23 +144,7 @@ public class SysFileService : IDynamicApiController, ITransient /// private async Task GetFileStreamResult(SysFile file, string fileName) { - var filePath = Path.Combine(file.FilePath ?? "", file.Id + file.Suffix); - if (_OSSProviderOptions.Enabled) - { - var httpRemoteService = App.GetRequiredService(); - var stream = await httpRemoteService.GetAsStreamAsync(await _OSSService.PresignedGetObjectAsync(file.BucketName, filePath, 5)); - return new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = fileName + file.Suffix }; - } - - if (App.Configuration["SSHProvider:Enabled"].ToBoolean()) - { - using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], - App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); - return new FileStreamResult(helper.OpenRead(filePath), "application/octet-stream") { FileDownloadName = fileName + file.Suffix }; - } - - var path = Path.Combine(App.WebHostEnvironment.WebRootPath, filePath); - return new FileStreamResult(new FileStream(path, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName + file.Suffix }; + return await _customFileProvider.GetFileStreamResultAsync(file, fileName); } /// @@ -162,42 +155,8 @@ public class SysFileService : IDynamicApiController, ITransient [DisplayName("下载指定文件Base64格式")] public async Task DownloadFileBase64([FromBody] string url) { - if (_OSSProviderOptions.Enabled) - { - using var httpClient = new HttpClient(); - HttpResponseMessage response = await httpClient.GetAsync(url); - if (response.IsSuccessStatusCode) - { - // 读取文件内容并将其转换为 Base64 字符串 - byte[] fileBytes = await response.Content.ReadAsByteArrayAsync(); - return Convert.ToBase64String(fileBytes); - } - throw new HttpRequestException($"Request failed with status code: {response.StatusCode}"); - } - - if (App.Configuration["SSHProvider:Enabled"].ToBoolean()) - { - var sysFile = await _sysFileRep.CopyNew().GetFirstAsync(u => u.Url == url) ?? throw Oops.Oh($"文件不存在"); - using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], - App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); - return Convert.ToBase64String(helper.ReadAllBytes(sysFile.FilePath)); - } - else - { - var sysFile = await _sysFileRep.CopyNew().GetFirstAsync(u => u.Url == url) ?? throw Oops.Oh($"文件不存在"); - var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, sysFile.FilePath); - if (!Directory.Exists(filePath)) - Directory.CreateDirectory(filePath); - - var realFile = Path.Combine(filePath, $"{sysFile.Id}{sysFile.Suffix}"); - if (!File.Exists(realFile)) - { - Log.Error($"DownloadFileBase64:文件[{realFile}]不存在"); - throw Oops.Oh($"文件[{sysFile.FilePath}]不存在"); - } - byte[] fileBytes = await File.ReadAllBytesAsync(realFile); - return Convert.ToBase64String(fileBytes); - } + var sysFile = await _sysFileRep.CopyNew().GetFirstAsync(u => u.Url == url) ?? throw Oops.Oh($"文件不存在"); + return await _customFileProvider.DownloadFileBase64Async(sysFile); } /// @@ -209,28 +168,9 @@ public class SysFileService : IDynamicApiController, ITransient [DisplayName("删除文件")] public async Task DeleteFile(DeleteFileInput input) { - var file = await _sysFileRep.GetByIdAsync(input.Id); - if (file != null) - { - await _sysFileRep.DeleteAsync(file); - - if (_OSSProviderOptions.Enabled) - { - await _OSSService.RemoveObjectAsync(file.BucketName, string.Concat(file.FilePath, "/", $"{input.Id}{file.Suffix}")); - } - else if (App.Configuration["SSHProvider:Enabled"].ToBoolean()) - { - var fullPath = string.Concat(file.FilePath, "/", file.Id + file.Suffix); - using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], - App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); - helper.DeleteFile(fullPath); - } - else - { - var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, file.FilePath ?? "", input.Id + file.Suffix); - if (File.Exists(filePath)) File.Delete(filePath); - } - } + var file = await _sysFileRep.GetByIdAsync(input.Id) ?? throw Oops.Oh($"文件不存在"); + await _sysFileRep.DeleteAsync(file); + await _customFileProvider.DeleteFileAsync(file); } /// @@ -349,59 +289,8 @@ public class SysFileService : IDynamicApiController, ITransient newFile.FileMd5 = fileMd5; var finalName = newFile.Id + suffix; // 文件最终名称 - if (_OSSProviderOptions.Enabled) - { - newFile.Provider = Enum.GetName(_OSSProviderOptions.Provider); - var filePath = string.Concat(path, "/", finalName); - await _OSSService.PutObjectAsync(newFile.BucketName, filePath, input.File.OpenReadStream()); - // http://<你的bucket名字>.oss.aliyuncs.com/<你的object名字> - // 生成外链地址 方便前端预览 - switch (_OSSProviderOptions.Provider) - { - case OSSProvider.Aliyun: - newFile.Url = $"{(_OSSProviderOptions.IsEnableHttps ? "https" : "http")}://{newFile.BucketName}.{_OSSProviderOptions.Endpoint}/{filePath}"; - break; - case OSSProvider.QCloud: - var protocol = _OSSProviderOptions.IsEnableHttps ? "https" : "http"; - newFile.Url = !string.IsNullOrWhiteSpace(_OSSProviderOptions.CustomHost) - ? $"{protocol}://{_OSSProviderOptions.CustomHost}/{filePath}" - : $"{protocol}://{newFile.BucketName}-{_OSSProviderOptions.Endpoint}.cos.{_OSSProviderOptions.Region}.myqcloud.com/{filePath}"; - break; - - case OSSProvider.Minio: - // 获取Minio文件的下载或者预览地址 - // newFile.Url = await GetMinioPreviewFileUrl(newFile.BucketName, filePath);// 这种方法生成的Url是有7天有效期的,不能这样使用 - // 需要在MinIO中的Buckets开通对 Anonymous 的readonly权限 - var customHost = _OSSProviderOptions.CustomHost; - if (string.IsNullOrWhiteSpace(customHost)) - customHost = _OSSProviderOptions.Endpoint; - newFile.Url = $"{(_OSSProviderOptions.IsEnableHttps ? "https" : "http")}://{customHost}/{newFile.BucketName}/{filePath}"; - break; - } - } - else if (App.Configuration["SSHProvider:Enabled"].ToBoolean()) - { - var fullPath = string.Concat(path.StartsWith('/') ? path : "/" + path, "/", finalName); - using SSHHelper helper = new(App.Configuration["SSHProvider:Host"], - App.Configuration["SSHProvider:Port"].ToInt(), App.Configuration["SSHProvider:Username"], App.Configuration["SSHProvider:Password"]); - helper.UploadFile(input.File.OpenReadStream(), fullPath); - } - else - { - newFile.Provider = ""; // 本地存储 Provider 显示为空 - var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, path); - if (!Directory.Exists(filePath)) - Directory.CreateDirectory(filePath); - - var realFile = Path.Combine(filePath, finalName); - await using (var stream = File.Create(realFile)) - { - await input.File.CopyToAsync(stream); - } - - newFile.Url = $"{newFile.FilePath}/{newFile.Id + newFile.Suffix}"; - } + newFile = await _customFileProvider.UploadFileAsync(input.File, newFile, path,finalName); await _sysFileRep.AsInsertable(newFile).ExecuteCommandAsync(); return newFile; }