服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-07-31 10f3247a8320da7e1e519c20b8014c65958301c2
Tiger.Api/Controllers/Base/BaseController.cs
@@ -532,19 +532,38 @@
        }
        #endregion
        #region 先删除后新增
        [HttpPost]
        public async Task<IActionResult> AddAfterDeleteAsync([FromBody] ApiAction action)
        {
            ApiAction response;
            try
            {
                response = action.GetResponse(await Biz.Base.AddAfterDeleteAsync(action.GetDataEntity()));
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
        #endregion
        #region 文件上传
        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="file"></param>
        /// <param name="entityName"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Upload(IFormFile file)
        public async Task<IActionResult> Upload([FromForm]string entityName, IFormFile file)
        {
            if (file == null || file.Length == 0)
                return BadRequest("No file uploaded.");
            var path = Path.Combine(@"D:\nginx-1.26.0\html", "upload", file.FileName);
            var folderName = entityName == "BAS_LABEL_TEMP" || entityName == "BAS_LABEL_VAR" ? "upload/Template": "upload";
            var path = Path.Combine($@"{BizConfig.Configuration["UploadAddress"]}", folderName, file.FileName);
            using (var stream = new FileStream(path, FileMode.Create))
            {