ResourceController.cs 837 B

1234567891011121314151617181920212223
  1. using CZFW.Core;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.AspNetCore.StaticFiles;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. namespace CZFW.CMS.Admin.Controllers
  9. {
  10. public class ResourceController:Controller
  11. {
  12. public IActionResult Load(string siteId, string fileType,string fileName)
  13. {
  14. //var path = $"{ConfigHelper.GetValue<string>("ResourcePathRoot")}\\{siteId}\\{fileType}\\{fileName}";
  15. var path = $"{ConfigHelper.GetValue<string>("ResourcePathRoot")}/{siteId}/{fileType}/{fileName}";
  16. var mimetypeProvider = new FileExtensionContentTypeProvider();
  17. var mimetype = mimetypeProvider.TryGetContentType(path, out string contentType);
  18. return PhysicalFile(path, contentType);
  19. }
  20. }
  21. }