课件管理 下载文件 命名后缀修改为年月日时分秒

master
xiaochanghai 10 months ago
parent 92e6e439ba
commit 20fc00e698
  1. 8
      Tiobon.Core.Api/Controllers/FileController.cs

@ -109,9 +109,9 @@ public class FileController : BaseApiController
string pathHeader = "wwwroot/files/" + filePath;
if (!Directory.Exists(pathHeader))
Directory.CreateDirectory(pathHeader);
long fileName = SnowFlakeSingle.instance.getID();
var fileName = upload.fileName.Replace("." + ext, "_") + DateTime.Now.ToString("yyyyMMddHHmmss");
filePath = "/files/" + filePath + "/" + $"{upload.fileName}_{fileName}.{ext}";
filePath = "/files/" + filePath + "/" + $"{fileName}.{ext}";
//var filepath = Path.Combine(pathHeader, file.FileName);
using (var stream = global::System.IO.File.Create("wwwroot/" + filePath))
{
@ -123,7 +123,7 @@ public class FileController : BaseApiController
fileAttachment.AttachFileName = upload.file.FileName;
fileAttachment.CreateBy = App.User.ID;
fileAttachment.CreateTime = DateTime.Now;
fileAttachment.AttachmentName = fileName.ToString();
fileAttachment.AttachmentName = fileName;
fileAttachment.AttachFileExtension = ext;
fileAttachment.AttachFileSize = upload.file.Length;
fileAttachment.PhysicsPath = filePath;
@ -139,7 +139,7 @@ public class FileController : BaseApiController
Id = fileAttachment.Id,
AttachFileExtension = fileAttachment.AttachFileExtension,
AttachFileName = fileAttachment.AttachFileName,
AttachmentName = fileAttachment.AttachmentName,
AttachmentName = fileName,
AttachmentNo = fileAttachment.AttachmentNo,
FileURL = fileAttachment.FileURL,
PhysicsPath = fileAttachment.PhysicsPath,

Loading…
Cancel
Save