Test.Core.Web/Controllers/FileController.cs
(完整代码) 1KBusing CommonUtils;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
namespace Test.Core.Web.Controllers
{
[SwaggerTag("文件")]
[Route("api/[controller]/[action]")]
public class FileController : ControllerBase
{
//static string FileRoot = "C:/FileRoot";
static string FileRoot = "./FileRoot";
[SwaggerOperation("上传")]
[HttpPost]
public ApiResult Upload([SwaggerParameter("文件")] IFormFile file)
{
FileUtil.SaveTo(FileRoot.Combine(file.Name), file.OpenReadStream());
return ApiResult.Ok(file.Name);
}
[SwaggerOperation("下载")]
[HttpGet]
public IActionResult Download([SwaggerParameter("路径")] string path)
{
return ApiResult.File(FileRoot.Combine(path));
}
[SwaggerOperation("下载")]
[HttpGet("{path}")]
public IActionResult Map([SwaggerParameter("路径")] string path)
{
return ApiResult.File(FileRoot.Combine(path));
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。