From c790b4bb5b3d1cffa6098b04c07c4f2ea4e2ad9a Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Mon, 14 Sep 2020 20:59:56 +0800 Subject: [PATCH] =?UTF-8?q?1.MinIO=E4=B8=8A=E4=BC=A0=E6=B7=BB=E5=8A=A0cont?= =?UTF-8?q?ent=20type=202.KindEditor=E5=BC=82=E6=AD=A5=E5=88=B7=E6=96=B0vu?= =?UTF-8?q?e=E7=BB=84=E4=BB=B6=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 11e69fca7ce94c8580437ee3b842a8bdaaef085f Former-commit-id: 8aa86bcda0a361eb98356f8c5681839b86b3c3df --- projects/Infrastructure/Web/Mvc/FileController.cs | 10 ++++++---- .../WebMVC/wwwroot/components/shared/edit/html.html | 5 ++++- projects/WebMVC/wwwroot/components/shared/layout.html | 5 ++--- .../linux-x64/publish/docker/conf/website/nginx.conf | 7 ++++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/projects/Infrastructure/Web/Mvc/FileController.cs b/projects/Infrastructure/Web/Mvc/FileController.cs index 8de53852..efb3d1ee 100644 --- a/projects/Infrastructure/Web/Mvc/FileController.cs +++ b/projects/Infrastructure/Web/Mvc/FileController.cs @@ -2,15 +2,16 @@ using Infrastructure.Extensions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Configuration; using Minio; using System; +using System.Collections.Generic; using System.Globalization; using System.IO; using System.IO.Compression; using System.Net.Http; using System.Security.Cryptography; -using System.Collections.Generic; namespace Infrastructure.Web.Mvc { @@ -96,9 +97,9 @@ namespace Infrastructure.Web.Mvc private string UploadMinIO(IFormFile file) { using var stream = file.OpenReadStream(); - var ext = GetExtension(file.FileName); + var ext = Path.GetExtension(file.FileName); var md5 = GetFileNameHash(stream); - var name = $"{md5}.{ext}"; + var name = $"{md5}{ext}"; var endpoint = this._cfg["minio:endpoint"]; var accessKey = this._cfg["minio:accessKey"]; var secretKey = this._cfg["minio:secretKey"]; @@ -139,7 +140,8 @@ namespace Infrastructure.Web.Mvc { ex.PrintStack(); stream.Position = 0; - minio.PutObjectAsync(bucketName, name, stream, stream.Length); + new FileExtensionContentTypeProvider().Mappings.TryGetValue(ext, out string contenttype); + minio.PutObjectAsync(bucketName, name, stream, stream.Length, contenttype); } var path = $"/{bucketName}/{name}"; return $"/dfs{path}"; diff --git a/projects/WebMVC/wwwroot/components/shared/edit/html.html b/projects/WebMVC/wwwroot/components/shared/edit/html.html index 445e5693..7800035b 100644 --- a/projects/WebMVC/wwwroot/components/shared/edit/html.html +++ b/projects/WebMVC/wwwroot/components/shared/edit/html.html @@ -16,7 +16,10 @@ width: '100%', allowImageUpload: true, uploadJson: vm.uploadUrl, - formatUploadUrl: false + formatUploadUrl: false, + afterChange: function () { + vm.$emit('update:value', this.html()); + } }); }, computed: { diff --git a/projects/WebMVC/wwwroot/components/shared/layout.html b/projects/WebMVC/wwwroot/components/shared/layout.html index 48dacca5..b77715ca 100644 --- a/projects/WebMVC/wwwroot/components/shared/layout.html +++ b/projects/WebMVC/wwwroot/components/shared/layout.html @@ -31,7 +31,7 @@