From 2e4f0249283b6043e3b9a7c9a6d452340692d28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Wed, 3 Nov 2021 19:20:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/FileController.cs | 8 +++++--- Yi.Vue/src/api/fileApi.js | 4 ++-- Yi.Vue/src/views/userInfo.vue | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs index 63d8ab79..40224c9b 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs @@ -36,12 +36,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers await _userService.UpdateAsync(user_data); return Result.Success(); } + + [Route("{type}/{fileNmae}")] [HttpGet] - public IActionResult Get(string type, string imageNmae) + public IActionResult Get(string type, string fileNmae) { - var path = Path.Combine($"wwwroot\\{type}", imageNmae); + var path = Path.Combine($"wwwroot\\{type}", fileNmae); var stream = System.IO.File.OpenRead(path); - var MimeType = Common.Helper.MimeHelper.GetMimeMapping(imageNmae); + var MimeType = Common.Helper.MimeHelper.GetMimeMapping(fileNmae); return new FileStreamResult(stream, MimeType); } diff --git a/Yi.Vue/src/api/fileApi.js b/Yi.Vue/src/api/fileApi.js index 6a999fbb..3b653b07 100644 --- a/Yi.Vue/src/api/fileApi.js +++ b/Yi.Vue/src/api/fileApi.js @@ -1,8 +1,8 @@ import myaxios from '@/util/myaxios' export default { - Upload(file) { + EditIcon(file) { return myaxios({ - url: '/File/Upload', + url: '/File/EditIcon', method: 'post', headers: { "Content-Type": "multipart/form-data" }, data: file diff --git a/Yi.Vue/src/views/userInfo.vue b/Yi.Vue/src/views/userInfo.vue index dfb67f98..ff20c18f 100644 --- a/Yi.Vue/src/views/userInfo.vue +++ b/Yi.Vue/src/views/userInfo.vue @@ -334,7 +334,7 @@ choiceImg() { const file = this.$refs.imgFile.files[0]; let formData = new FormData(); formData.append("img", file); - fileApi.Upload(formData).then(resp=>{ + fileApi.EditIcon(formData).then(resp=>{ this.init(); }) },