移动系统liao
2024-08-15 f5ff0b0492e2799226234dfd8633877b8f9a81d7
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace EzUpFile
{
    /// <summary>
    /// 文件上传下载
    /// </summary>
    [DynamicApiController]
    [ApiDescriptionSettings("FileUpdata@0")]
    public class UpFileController
    {
 
        /// <summary>
        /// 上传附件
        /// </summary>
        /// <param name="fileUploadService"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<string> UpdateFile([FromServices] IEzFileUploadService fileUploadService, IFormFile file)
        {
            return await fileUploadService.UploadFiles();
        }
        /// <summary>
        /// 获取到客户端的IPv4
        /// </summary>
        /// <param name="httpContextAccessor"></param>
        /// <returns></returns>
        [HttpGet]
        public string GetIp4([FromServices] IHttpContextAccessor httpContextAccessor)
        {
            var httpc = httpContextAccessor.HttpContext;
            var ipv4 = httpc.GetRemoteIpAddressToIPv4();
            return ipv4;
        }
        /// <summary>
        /// 上传附件
        /// </summary>
        /// <param name="fileUploadService"></param>
        /// <param name="Param"></param>    
        /// <returns></returns>
        [HttpPost]
        public async Task<string> UpdateFileBase64([FromServices] IEzFileUploadService fileUploadService, UpDataFileData Param)
        {
            return await fileUploadService.UploadFilesFByBase64(Param.FileBase64);
        }
        [HttpPost]
        public async Task<bool> DelFile([FromServices] IEzFileUploadService fileUploadService, DelFileData Param)
        {
            return await fileUploadService.DelFile(Param.FilePath);
        }
    }
    /// <summary>
    /// 上传数据
    /// </summary>
    public class UpDataFileData
 
    {
        /// <summary>
        /// 数据base64
        /// </summary>
        public string FileBase64 { get; set; }
    }
    /// <summary>
    /// 上传数据
    /// </summary>
    public class DelFileData
 
    {
        /// <summary>
        /// 数据base64
        /// </summary>
        public string FilePath { get; set; }
    }
}