添加删除文件接口
This commit is contained in:
parent
37ed5273fc
commit
9c323ddebe
|
@ -0,0 +1,35 @@
|
||||||
|
using Competition.Common.Util;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CompetitionAPI.Controllers.version
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class DeleteFileController : Controller
|
||||||
|
{
|
||||||
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
|
|
||||||
|
public DeleteFileController(IWebHostEnvironment webHostEnvironment)
|
||||||
|
{
|
||||||
|
_webHostEnvironment = webHostEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件接口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Path">文件路径</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public JsonResult Index(string Path)
|
||||||
|
{
|
||||||
|
var webRootPath = _webHostEnvironment.WebRootPath;
|
||||||
|
if (System.IO.File.Exists(webRootPath + "/" + Path))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(webRootPath + "/" + Path);
|
||||||
|
}
|
||||||
|
return Json(Tool.GetJsonWithCode(APICode.Success, "删除成功"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue