/// <summary> /// 签名验证 /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(ActionExecutingContext actionContext) { base.OnActionExecuting(actionContext); bool ispass = Uploader.CheckUploadFile(actionContext.HttpContext); if (!ispass) { actionContext.Result = APIResponse.Instance.ContentResult(StateCode.State_5); } return; }
/// <summary> /// 处理进程 /// </summary> public async override void Process() { byte[] uploadFileBytes = null; //文件内容 string uploadFileName = null; //文件名 if (UploadConfig.Base64) { uploadFileName = UploadConfig.Base64Filename; uploadFileBytes = Convert.FromBase64String(Request.Form[UploadConfig.UploadFieldName]); } else { } try { //上传状态 StateCode state = StateCode.State_500; //原文件名,url地址,data:上传后新生成的名 string original = string.Empty, url = string.Empty, data = string.Empty; //是否使用OSS上传功能 if (ConfigManage.AppSettings <bool>("WeChatSettings:IsOpenOss")) { var result = OSSUpload.UploadFile(Context); state = result.state; url = result.url; data = result.data; original = result.original; } else { if (Uploader.CheckUploadFile(Context)) { var result = await Uploader.UploadFile(Context); state = result.state; url = result.url; data = result.data; original = result.original; } else { Result.ErrorMessage = "上传票据校验失败"; } } if (state == StateCode.State_200) { Result.State = UploadState.Success; } //原始路径名 Result.OriginFileName = original; Result.Url = url; Result.Data = data; } catch (Exception e) { Result.State = UploadState.FileAccessError; Result.ErrorMessage = e.Message; } finally { WriteResult(); } }