Browse Source

更新包

懒得勤快 4 years ago
parent
commit
e70afc1c9f

+ 4 - 4
src/Masuit.MyBlogs.Core/Controllers/ErrorController.cs

@@ -89,19 +89,19 @@ namespace Masuit.MyBlogs.Core.Controllers
                         break;
                     case NotFoundException ex:
                         Response.StatusCode = 404;
-                        return Request.Method.Equals(HttpMethods.Get) ? (ActionResult)View("Index") : Json(new
+                        return Request.Method.Equals(HttpMethods.Get) ? View("Index") : Json(new
                         {
                             StatusCode = 404,
                             Success = false,
                             ex.Message
                         });
-                    case AccessDenyException _:
+                    case AccessDenyException:
                         var (location, network) = ip.GetIPLocation();
                         var tips = Template.Create(CommonHelper.SystemSettings.GetOrAdd("AccessDenyTips", @"<h4>遇到了什么问题?</h4>
                 <h4>基于主观因素考虑,您所在的地区暂时不允许访问本站,如有疑问,请联系站长!或者请联系站长开通本站的访问权限!</h4>")).Set("clientip", ip.ToString()).Set(nameof(location), location).Set(nameof(network), network).Render();
                         Response.StatusCode = 403;
                         return View("AccessDeny", tips);
-                    case TempDenyException _:
+                    case TempDenyException:
                         Response.StatusCode = 403;
                         return View("TempDeny");
                     default:
@@ -111,7 +111,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
 
             Response.StatusCode = 503;
-            return Request.Method.Equals(HttpMethods.Get) ? (ActionResult)View() : Json(new
+            return Request.Method.Equals(HttpMethods.Get) ? View() : Json(new
             {
                 StatusCode = 503,
                 Success = false,

+ 10 - 8
src/Masuit.MyBlogs.Core/Controllers/UploadController.cs

@@ -54,9 +54,9 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <returns></returns>
         [HttpPost]
-        public async Task<ActionResult> UploadWord()
+        public async Task<ActionResult> UploadWord(CancellationToken cancellationToken)
         {
-            var form = await Request.ReadFormAsync();
+            var form = await Request.ReadFormAsync(cancellationToken);
             var files = form.Files;
             if (files.Count <= 0)
             {
@@ -177,7 +177,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="path"></param>
         /// <returns></returns>
         [Route("download")]
-        [Route("download/{path}")]
+        [Route("download/{**path}")]
         public ActionResult Download(string path)
         {
             if (string.IsNullOrEmpty(path)) return Content("null");
@@ -270,17 +270,19 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             string path;
             string filename = SnowFlake.GetInstance().GetUniqueId() + Path.GetExtension(file.FileName);
+            var pathBase = CommonHelper.SystemSettings.GetOrAdd("UploadPath", "upload").Trim('/', '\\');
             switch (file.ContentType)
             {
                 case var _ when file.ContentType.StartsWith("image"):
                     {
-                        var (url, success) = await imagebedClient.UploadImage(file.OpenReadStream(), file.FileName, cancellationToken);
+                        await using var stream = file.OpenReadStream();
+                        var (url, success) = await imagebedClient.UploadImage(stream, file.FileName, cancellationToken);
                         if (success)
                         {
                             return ResultData(url);
                         }
 
-                        path = Path.Combine(HostEnvironment.WebRootPath, CommonHelper.SystemSettings.GetOrAdd("UploadPath", "upload").Trim('/', '\\'), "images", filename);
+                        path = Path.Combine(HostEnvironment.WebRootPath, pathBase, "images", filename);
                         var dir = Path.GetDirectoryName(path);
                         Directory.CreateDirectory(dir);
                         await using var fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
@@ -288,13 +290,13 @@ namespace Masuit.MyBlogs.Core.Controllers
                         break;
                     }
                 case var _ when file.ContentType.StartsWith("audio") || file.ContentType.StartsWith("video"):
-                    path = Path.Combine(HostEnvironment.WebRootPath, CommonHelper.SystemSettings.GetOrAdd("UploadPath", "upload").Trim('/', '\\'), "media", filename);
+                    path = Path.Combine(HostEnvironment.WebRootPath, pathBase, "media", filename);
                     break;
                 case var _ when file.ContentType.StartsWith("text") || (ContentType.Doc + "," + ContentType.Xls + "," + ContentType.Ppt + "," + ContentType.Pdf).Contains(file.ContentType):
-                    path = Path.Combine(HostEnvironment.WebRootPath, CommonHelper.SystemSettings.GetOrAdd("UploadPath", "upload").Trim('/', '\\'), "docs", filename);
+                    path = Path.Combine(HostEnvironment.WebRootPath, pathBase, "docs", filename);
                     break;
                 default:
-                    path = Path.Combine(HostEnvironment.WebRootPath, CommonHelper.SystemSettings.GetOrAdd("UploadPath", "upload").Trim('/', '\\'), "files", filename);
+                    path = Path.Combine(HostEnvironment.WebRootPath, pathBase, "files", filename);
                     break;
             }
             try

+ 2 - 2
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -34,7 +34,7 @@
         <PackageReference Include="CacheManager.StackExchange.Redis" Version="1.2.0" />
         <PackageReference Include="CHTCHSConv" Version="1.0.0" />
         <PackageReference Include="CSRedisCore" Version="3.6.6" />
-        <PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="2.5.0" />
+        <PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="2.7.0" />
         <PackageReference Include="Hangfire" Version="1.7.22" />
         <PackageReference Include="Hangfire.Autofac" Version="2.3.1" />
         <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
@@ -60,7 +60,7 @@
         <PackageReference Include="TimeZoneConverter" Version="3.5.0" />
         <PackageReference Include="WilderMinds.RssSyndication" Version="1.7.0" />
         <PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
-        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.1.33" />
+        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.1.35" />
     </ItemGroup>
     <ItemGroup>
         <Content Update="appsettings.json">