yzp пре 2 година
родитељ
комит
19bda37a4a

+ 40 - 35
Admin.NET/Admin.NET.Core/Service/File/Dto/FileInput.cs

@@ -1,38 +1,38 @@
-// 麻省理工学院许可证
-//
-// 版权所有 (c) 2021-2023 zuohuaijun,大名科技(天津)有限公司  联系电话/微信:18020030720  QQ:515096995
-//
-// 特此免费授予获得本软件的任何人以处理本软件的权利,但须遵守以下条件:在所有副本或重要部分的软件中必须包括上述版权声明和本许可声明。
-//
-// 软件按“原样”提供,不提供任何形式的明示或暗示的保证,包括但不限于对适销性、适用性和非侵权的保证。
-// 在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是因合同、侵权或其他方式引起的,与软件或其使用或其他交易有关。
-
-namespace Admin.NET.Core.Service;
-
-public class FileInput : BaseIdInput
-{
-}
-
-public class PageFileInput : BasePageInput
-{
-    /// <summary>
-    /// 文件名称
-    /// </summary>
-    public string FileName { get; set; }
-
-    /// <summary>
-    /// 开始时间
-    /// </summary>
-    public DateTime? StartTime { get; set; }
-
-    /// <summary>
-    /// 结束时间
-    /// </summary>
-    public DateTime? EndTime { get; set; }
-}
-
-public class DeleteFileInput : BaseIdInput
-{
+// 麻省理工学院许可证
+//
+// 版权所有 (c) 2021-2023 zuohuaijun,大名科技(天津)有限公司  联系电话/微信:18020030720  QQ:515096995
+//
+// 特此免费授予获得本软件的任何人以处理本软件的权利,但须遵守以下条件:在所有副本或重要部分的软件中必须包括上述版权声明和本许可声明。
+//
+// 软件按“原样”提供,不提供任何形式的明示或暗示的保证,包括但不限于对适销性、适用性和非侵权的保证。
+// 在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是因合同、侵权或其他方式引起的,与软件或其使用或其他交易有关。
+
+namespace Admin.NET.Core.Service;
+
+public class FileInput : BaseIdInput
+{
+}
+
+public class PageFileInput : BasePageInput
+{
+    /// <summary>
+    /// 文件名称
+    /// </summary>
+    public string FileName { get; set; }
+
+    /// <summary>
+    /// 开始时间
+    /// </summary>
+    public DateTime? StartTime { get; set; }
+
+    /// <summary>
+    /// 结束时间
+    /// </summary>
+    public DateTime? EndTime { get; set; }
+}
+
+public class DeleteFileInput : BaseIdInput
+{
 }
 
 public class UploadFileFromBase64Input
@@ -47,6 +47,11 @@ public class UploadFileFromBase64Input
     /// </summary>
     public string ContentType { get; set; }
 
+    /// <summary>
+    /// 文件名称
+    /// </summary>
+    public string FileName { get; set; }
+
     /// <summary>
     /// 保存路径
     /// </summary>

+ 7 - 3
Admin.NET/Admin.NET.Core/Service/File/SysFileService.cs

@@ -10,6 +10,7 @@
 using Aliyun.OSS.Util;
 using Furion.VirtualFileServer;
 using OnceMi.AspNetCore.OSS;
+using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinTagsMembersGetBlackListResponse.Types;
 
 namespace Admin.NET.Core.Service;
 
@@ -77,13 +78,16 @@ public class SysFileService : IDynamicApiController, ITransient
     }
 
     [NonAction]
-    public async Task<FileOutput> UploadFileFromBase64([Required] string strBase64, string contentType, string? path)
+    public async Task<FileOutput> UploadFileFromBase64(string strBase64, string fileName, string contentType, string? path)
     {
         byte[] fileData = Convert.FromBase64String(strBase64);
         MemoryStream ms = new MemoryStream();
         ms.Write(fileData);
         ms.Seek(0, SeekOrigin.Begin);
-        string fileName = "base64.jpg";
+        if (string.IsNullOrEmpty(fileName))
+            fileName = "1.jpg";
+        if (string.IsNullOrEmpty(contentType))
+            contentType = contentType;
         IFormFile formFile = new FormFile(ms, 0, fileData.Length, "file", fileName)
         {
             Headers = new HeaderDictionary(),
@@ -101,7 +105,7 @@ public class SysFileService : IDynamicApiController, ITransient
     [HttpPost]
     public async Task<FileOutput> UploadFileFromBase64(UploadFileFromBase64Input input)
     {
-        return await UploadFileFromBase64(input.FileDataBase64, input.ContentType, input.Path);
+        return await UploadFileFromBase64(input.FileDataBase64, input.FileName, input.ContentType, input.Path);
     }
 
     /// <summary>

+ 6 - 0
Web/src/api-services/models/upload-file-from-base64-input.ts

@@ -29,6 +29,12 @@ export interface UploadFileFromBase64Input {
      * @memberof UploadFileFromBase64Input
      */
     contentType?: string | null;
+    /**
+     * 文件名称
+     * @type {string}
+     * @memberof UploadFileFromBase64Input
+     */
+    fileName?: string | null;
     /**
      * 保存路径
      * @type {string}