c# API接受图片文件以Base64格式上传图片

 /// base64上传图片
        /// </summary>
        /// <returns>成功上传返回上传后的文件名</returns>
        [HttpPost]
        public async Task<IHttpActionResult> UpLoadImageBase64()
        {
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            string text = context.Request.Form["file"];

            Stream stream = ]));
            using (HttpClient client = new HttpClient())
            {
                var request = new HttpRequestMessage(HttpMethod.Post, ConfigurationManager.AppSettings["Imgaes"].ToString() + "/Upload");
                var content = new MultipartFormDataContent();

                //client.DefaultRequestHeaders.Add("fileext", HttpContext.Request.Headers["fileext"]);
                content.Add(new StreamContent(stream), "file", "file.jpg");
                request.Content = content;
                var response = await client.SendAsync(request);
                response.EnsureSuccessStatusCode();
                var filenamestr = await response.Content.ReadAsStringAsync();//返回结果
            }
            return Ok();
        }
上一篇:Maya制作模拟球延绳子滚下效果的方法


下一篇:FireWorks制作炫丽的吊坠+刷光GIF动态效果