浏览代码

修复oss配置指定url上传文件返回linkurl错误的问题

zhontai 2 年之前
父节点
当前提交
d3c00df68e
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. 10 5
      src/platform/ZhonTai.Admin/Services/File/FileService.cs

+ 10 - 5
src/platform/ZhonTai.Admin/Services/File/FileService.cs

@@ -188,14 +188,19 @@ public class FileService : BaseService, IFileService, IDynamicApi
                     OSSProvider.HuaweiCloud => $"{oSSOptions.BucketName}.{oSSOptions.Endpoint}",
                     _ => ""
                 };
+
+                if (url.IsNull())
+                {
+                    throw ResultOutput.Exception($"请配置{oSSOptions.Provider}的Url参数");
+                }
+
+                var urlProtocol = oSSOptions.IsEnableHttps ? "https" : "http";
+                fileEntity.LinkUrl = $"{urlProtocol}://{url}/{filePath}";
             }
-            if (url.IsNull())
+            else
             {
-                throw ResultOutput.Exception($"请配置{oSSOptions.Provider}的Url参数");
+                fileEntity.LinkUrl = $"{url}/{filePath}";
             }
-
-            var urlProtocol = oSSOptions.IsEnableHttps ? "https" : "http";
-            fileEntity.LinkUrl = $"{urlProtocol}://{url}/{filePath}";
         }
         else
         {