| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using SiteCore.ueditor;
- using System.Web;
- using System.Web.SessionState;
- namespace SiteCore.Handler
- {
- public class editorSrv : BaseHandler, IHttpHandler, IRequiresSessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- con = context;
- ueditor.Handler action = null;
- switch (context.Request["action"])
- {
- case "config":
- action = new ConfigHandler(context);
- break;
- case "uploadimage":
- action = new UploadHandler(context, new UploadConfig()
- {
- AllowExtensions = Config.GetStringList("imageAllowFiles"),
- PathFormat = Config.GetString("imagePathFormat"),
- SizeLimit = Config.GetInt("imageMaxSize"),
- UploadFieldName = Config.GetString("imageFieldName")
- });
- //string err = "{\"originalName\":\"\",\"name\":\"\",\"url\":\"\",\"size\":\"0\",\"state\":\"没有上传文件\",\"type\":\"jpg\"}";
- //if (context.Request.Files.Count < 1)
- //{
- // context.Response.Write(err);
- // return;
- //}
- //string fn = CurrentUser.UserID + "_" + DateTime.Now.ToString("yyMMddHHmmss");
- //try
- //{
- // HttpPostedFile postFile = context.Request.Files[0];
- // if (postFile != null)
- // {
- // string errMsg = "";
- // if (!ImageHandler.CheckImage(postFile, out errMsg)) return;
- // string saveFile = Path.Combine(webConfig.umPicPath, fn + ".jpg");
- // string result = "";
- // using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream))
- // {
- // result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 800, "", 9, 3);
- // }
- // context.Response.Write("{\"originalName\":\"" + postFile.FileName + "\",\"name\":\"" + fn + ".jpg\",\"url\":\"" + fn + ".jpg\",\"size\":\"0\",\"state\":\"SUCCESS\",\"type\":\"jpg\"}");
- // return;
- // }
- //}
- //catch
- //{
- // context.Response.Write("{\"originalName\":\"\",\"name\":\"\",\"url\":\"上传成功!\",\"size\":\"0\",\"state\":\"图片上专失败\",\"type\":\"jpg\"}");
- // return;
- //}
- break;
- case "uploadscrawl":
- action = new UploadHandler(context, new UploadConfig()
- {
- AllowExtensions = new string[] { ".png" },
- PathFormat = Config.GetString("scrawlPathFormat"),
- SizeLimit = Config.GetInt("scrawlMaxSize"),
- UploadFieldName = Config.GetString("scrawlFieldName"),
- Base64 = true,
- Base64Filename = "scrawl.png"
- });
- break;
- case "uploadvideo":
- action = new UploadHandler(context, new UploadConfig()
- {
- AllowExtensions = Config.GetStringList("videoAllowFiles"),
- PathFormat = Config.GetString("videoPathFormat"),
- SizeLimit = Config.GetInt("videoMaxSize"),
- UploadFieldName = Config.GetString("videoFieldName")
- });
- break;
- case "uploadfile":
- action = new UploadHandler(context, new UploadConfig()
- {
- AllowExtensions = Config.GetStringList("fileAllowFiles"),
- PathFormat = Config.GetString("filePathFormat"),
- SizeLimit = Config.GetInt("fileMaxSize"),
- UploadFieldName = Config.GetString("fileFieldName")
- });
- break;
- case "listimage":
- action = new ListFileManager(context, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"));
- break;
- case "listfile":
- action = new ListFileManager(context, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"));
- break;
- case "catchimage":
- action = new CrawlerHandler(context);
- break;
- default:
- action = new NotSupportedHandler(context);
- break;
- }
- action.Process();
- }
- }
- }
|