Merge pull request !8 from Argo-QQ/dev-#ITBTJ
This commit is contained in:
commit
885c39c6df
|
@ -1,5 +1,6 @@
|
|||
using Bootstrap.Admin.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
|
||||
|
@ -87,8 +88,9 @@ namespace Bootstrap.Admin.Controllers
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <returns></returns>
|
||||
public ActionResult Profiles() => View(new ProfilesModel(this));
|
||||
public ActionResult Profiles([FromServices]IHostingEnvironment host) => View(new ProfilesModel(this, host));
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
var webSiteUrl = DictHelper.RetrieveIconFolderPath();
|
||||
fileName = string.Format("{0}{1}", userName, Path.GetExtension(uploadFile.FileName));
|
||||
var fileUrl = string.Format("{0}{1}", webSiteUrl, fileName);
|
||||
var filePath = Path.Combine(env.WebRootPath, webSiteUrl.Replace("~", string.Empty).Replace("/", "\\").TrimStart('\\') + fileName);
|
||||
var filePath = Path.Combine(env.WebRootPath, webSiteUrl.Replace("~", string.Empty).Replace('/', Path.DirectorySeparatorChar).TrimStart(Path.DirectorySeparatorChar) + fileName);
|
||||
var fileFolder = Path.GetDirectoryName(filePath);
|
||||
fileSize = uploadFile.Length;
|
||||
if (!Directory.Exists(fileFolder)) Directory.CreateDirectory(fileFolder);
|
||||
|
@ -53,7 +53,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
fileName = files["key"];
|
||||
if (!fileName.Equals("default.jpg"))
|
||||
{
|
||||
fileName = Path.Combine(env.WebRootPath, $"images\\uploader\\{fileName}");
|
||||
fileName = Path.Combine(env.WebRootPath, $"images{Path.DirectorySeparatorChar}uploader{Path.DirectorySeparatorChar}{fileName}");
|
||||
try
|
||||
{
|
||||
if (System.IO.File.Exists(fileName)) System.IO.File.Delete(fileName);
|
||||
|
|
|
@ -22,13 +22,13 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="controller"></param>
|
||||
public ProfilesModel(ControllerBase controller) : base(controller)
|
||||
public ProfilesModel(ControllerBase controller, IHostingEnvironment host) : base(controller)
|
||||
{
|
||||
var host = controller.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
|
||||
if (host != null)
|
||||
{
|
||||
var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', '\\'));
|
||||
var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', Path.DirectorySeparatorChar));
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
Size = new FileInfo(fileName).Length;
|
||||
|
|
Loading…
Reference in New Issue