/
FileController.cs
52 lines (49 loc) · 1.4 KB
/
FileController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Extension;
using YiSha.Util.Model;
namespace YiSha.Admin.Web.Controllers
{
public class FileController : BaseController
{
#region 上传单个文件
[HttpPost]
[AuthorizeFilter]
public async Task<TData<string>> UploadFile(int fileModule, IFormCollection fileList)
{
TData<string> obj = await FileHelper.UploadFile(fileModule, fileList.Files);
return obj;
}
#endregion
#region 删除单个文件
[HttpPost]
[AuthorizeFilter]
public TData<string> DeleteFile(int fileModule, string filePath)
{
TData<string> obj = FileHelper.DeleteFile(fileModule, filePath);
return obj;
}
#endregion
#region 下载文件
[HttpGet]
public FileContentResult DownloadFile(string filePath, int delete = 1)
{
TData<FileContentResult> obj = FileHelper.DownloadFile(filePath, delete);
if (obj.Tag == 1)
{
return obj.Data;
}
else
{
throw new Exception("下载失败:" + obj.Message);
}
}
#endregion
}
}