kazelee
10 天以前 b928a2f0011fc867d7d219cfff4b764250f5b778
api/ImageController.cs
@@ -5,13 +5,19 @@
using System.Web;
using System.Web.Http;
namespace HH.WCS.Mobox3.AnGang.api {
    //[RoutePrefix("api/image")]
public class ImageController : ApiController {
    private readonly string _baseStoragePath = HttpContext.Current.Server.MapPath("~/StaticStorage");
        //private readonly string _baseStoragePath = HttpContext.Current.Server.MapPath("~/StaticStorage");
        private readonly string _baseStoragePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StaticStorage");
    private readonly string[] _allowedExtensions = { ".jpg", ".jpeg", ".png", ".gif", ".bmp" };
    // 上传图片接口
    [HttpPost]
    [Route("api/image/upload")]
        //[ActionName("Upload")]
        //[Route("api/image/upload")]
        [Route("UploadImage")]
    public HttpResponseMessage UploadImage() {
        try {
            if (!Request.Content.IsMimeMultipartContent()) {
@@ -66,6 +72,7 @@
    // 获取图片接口 - 实际由静态文件处理,这里只是示例
    [HttpGet]
        //[ActionName("Get")]
    [Route("static/image/{year}/{month}/{day}/{filename}")]
    public HttpResponseMessage GetImage(string year, string month, string day, string filename) {
        try {
@@ -107,3 +114,4 @@
        }
    }
}
}