controller.ashx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <%@ WebHandler Language="C#" Class="UEditorHandler" %>
  2. using System;
  3. using System.Web;
  4. using System.IO;
  5. using System.Collections;
  6. using Newtonsoft.Json;
  7. public class UEditorHandler : IHttpHandler
  8. {
  9. public void ProcessRequest(HttpContext context)
  10. {
  11. Handler action = null;
  12. switch (context.Request["action"])
  13. {
  14. case "config":
  15. action = new ConfigHandler(context);
  16. break;
  17. case "uploadimage":
  18. action = new UploadHandler(context, new UploadConfig()
  19. {
  20. AllowExtensions = Config.GetStringList("imageAllowFiles"),
  21. PathFormat = Config.GetString("imagePathFormat"),
  22. SizeLimit = Config.GetInt("imageMaxSize"),
  23. UploadFieldName = Config.GetString("imageFieldName"),
  24. PhysicalPath = Config.GetString("imagePhysicalPath")
  25. });
  26. break;
  27. case "uploadscrawl":
  28. action = new UploadHandler(context, new UploadConfig()
  29. {
  30. AllowExtensions = new string[] { ".png" },
  31. PathFormat = Config.GetString("scrawlPathFormat"),
  32. SizeLimit = Config.GetInt("scrawlMaxSize"),
  33. UploadFieldName = Config.GetString("scrawlFieldName"),
  34. PhysicalPath = Config.GetString("scrawlPhysicalPath"),
  35. Base64 = true,
  36. Base64Filename = "scrawl.png"
  37. });
  38. break;
  39. case "uploadvideo":
  40. action = new UploadHandler(context, new UploadConfig()
  41. {
  42. AllowExtensions = Config.GetStringList("videoAllowFiles"),
  43. PathFormat = Config.GetString("videoPathFormat"),
  44. PhysicalPath = Config.GetString("videoPhysicalPath"),
  45. SizeLimit = Config.GetInt("videoMaxSize"),
  46. UploadFieldName = Config.GetString("videoFieldName")
  47. });
  48. break;
  49. case "uploadfile":
  50. action = new UploadHandler(context, new UploadConfig()
  51. {
  52. AllowExtensions = Config.GetStringList("fileAllowFiles"),
  53. PathFormat = Config.GetString("filePathFormat"),
  54. PhysicalPath = Config.GetString("filePhysicalPath"),
  55. SizeLimit = Config.GetInt("fileMaxSize"),
  56. UploadFieldName = Config.GetString("fileFieldName")
  57. });
  58. break;
  59. case "listimage":
  60. action = new ListFileManager(context, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"));
  61. break;
  62. case "listfile":
  63. action = new ListFileManager(context, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"));
  64. break;
  65. case "catchimage":
  66. action = new CrawlerHandler(context);
  67. break;
  68. default:
  69. action = new NotSupportedHandler(context);
  70. break;
  71. }
  72. action.Process();
  73. }
  74. public bool IsReusable
  75. {
  76. get
  77. {
  78. return false;
  79. }
  80. }
  81. }