From 9f21b5dad704aafd240e101f138a20c550c63d91 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 25 Oct 2024 13:54:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Controllers/FileController.cs | 11 ++++++----- .../Ghre/Ghre_AttachmentServices.cs | 17 +++++++++-------- .../Ghre/Ghre_CourseWareServices.cs | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/FileController.cs b/Tiobon.Core.Api/Controllers/FileController.cs index b7692662..cadb119a 100644 --- a/Tiobon.Core.Api/Controllers/FileController.cs +++ b/Tiobon.Core.Api/Controllers/FileController.cs @@ -155,10 +155,10 @@ public class FileController : BaseApiController AttachFileName = fileAttachment.AttachFileName, AttachmentName = fileName, AttachmentNo = fileAttachment.AttachmentNo, - FileURL = fileAttachment.FileURL, - PhysicsPath = fileAttachment.PhysicsPath, - RelativePath = fileAttachment.RelativePath, - ThumbnailPath = fileAttachment.ThumbnailPath, + FileURL = "/Advanced" + fileAttachment.FileURL, + PhysicsPath = "/Advanced" + fileAttachment.PhysicsPath, + RelativePath = "/Advanced" + fileAttachment.RelativePath, + ThumbnailPath = "/Advanced" + fileAttachment.ThumbnailPath, AttachFileSize = fileAttachment.AttachFileSize, }); @@ -226,12 +226,13 @@ public class FileController : BaseApiController /// /// 主键ID /// - [HttpGet("DownloadByPath/{path}"), AllowAnonymous] + [HttpGet("DownloadByPath"), AllowAnonymous] public async Task DownloadByPath(string path) { try { path = WebUtility.UrlDecode(path); + path = path.Replace("/Advanced", null); var file = await _ghre_AttachmentServices.QuerySingle(x => x.RelativePath == path); return await Download(file.Id); diff --git a/Tiobon.Core.Services/Ghre/Ghre_AttachmentServices.cs b/Tiobon.Core.Services/Ghre/Ghre_AttachmentServices.cs index d3241d3c..19b85f18 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_AttachmentServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_AttachmentServices.cs @@ -39,16 +39,17 @@ namespace Tiobon.Core.Services if (upload.chunkIndex == upload.totalChunks - 1) { - var id = SnowFlakeSingle.Instance.NextId(); - await FileMerge(upload.id, ".mp4", id); - using var _context = ContextFactory.CreateContext(); - var ext = string.Empty; if (string.IsNullOrEmpty(file.FileName) == false) { var dotPos = upload.fileName.LastIndexOf('.'); ext = upload.fileName.Substring(dotPos + 1); } + var id = SnowFlakeSingle.Instance.NextId(); + await FileMerge(upload.id, "."+ ext, id); + using var _context = ContextFactory.CreateContext(); + + var filePath = $"/files/upload/{id}.{ext}"; var fileAttachment = new Ghre_Attachment(); fileAttachment.Id = SnowFlakeSingle.Instance.NextId(); @@ -74,10 +75,10 @@ namespace Tiobon.Core.Services AttachFileName = fileAttachment.AttachFileName, AttachmentName = fileAttachment.AttachmentName, AttachmentNo = fileAttachment.AttachmentNo, - FileURL = fileAttachment.FileURL, - PhysicsPath = fileAttachment.PhysicsPath, - RelativePath = fileAttachment.RelativePath, - ThumbnailPath = fileAttachment.ThumbnailPath, + FileURL = "/Advanced" + fileAttachment.FileURL, + PhysicsPath = "/Advanced" + fileAttachment.PhysicsPath, + RelativePath = "/Advanced" + fileAttachment.RelativePath, + ThumbnailPath = "/Advanced" + fileAttachment.ThumbnailPath, AttachFileSize = fileAttachment.AttachFileSize, }); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs index b41be796..47231e7b 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs @@ -201,7 +201,7 @@ public class Ghre_CourseWareServices : BaseServices.OprateFailed("无效的课件ID!"); var attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == id); var webRootPath = _hostingEnvironment.WebRootPath; - var outPath = $"/files/upload/{result.CourseWareName}_{result.VersionNo}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip"; + var outPath = $"/Advanced/files/upload/{result.CourseWareName}_{result.VersionNo}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip"; var files = attachments.Select(x => $"{webRootPath}{"\\" + x.RelativePath}").ToArray(); if (files.Length > 0) {