public async Task <IHttpActionResult> UploadPic()
        {
            // 检查是否是 multipart/form-data
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                return(Json(new ApiResult(OperationResultType.Error, "请求数据格式不正确")));
            }
            var paths = await ApiUploadHelper.Upload(Request.Content);

            if (!paths.Any())
            {
                return(Json(new ApiResult(OperationResultType.NoChanged, "上传失败")));
            }
            return(Json(new ApiResult("上传成功", paths.First())));
        }
Exemple #2
0
        public async Task <List <string> > UploadPics()
        {
            // 检查是否是 multipart/form-data
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                throw new UserFriendlyException("请求数据格式不正确");
            }
            var paths = await ApiUploadHelper.Upload(Request.Content);

            if (!paths.Any())
            {
                throw new UserFriendlyException("上传失败");
            }
            return(paths);
        }