You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.0 KiB

2 years ago
  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. });
  25. break;
  26. case "uploadscrawl":
  27. action = new UploadHandler(context, new UploadConfig()
  28. {
  29. AllowExtensions = new string[] { ".png" },
  30. PathFormat = Config.GetString("scrawlPathFormat"),
  31. SizeLimit = Config.GetInt("scrawlMaxSize"),
  32. UploadFieldName = Config.GetString("scrawlFieldName"),
  33. Base64 = true,
  34. Base64Filename = "scrawl.png"
  35. });
  36. break;
  37. case "uploadvideo":
  38. action = new UploadHandler(context, new UploadConfig()
  39. {
  40. AllowExtensions = Config.GetStringList("videoAllowFiles"),
  41. PathFormat = Config.GetString("videoPathFormat"),
  42. SizeLimit = Config.GetInt("videoMaxSize"),
  43. UploadFieldName = Config.GetString("videoFieldName")
  44. });
  45. break;
  46. case "uploadfile":
  47. action = new UploadHandler(context, new UploadConfig()
  48. {
  49. AllowExtensions = Config.GetStringList("fileAllowFiles"),
  50. PathFormat = Config.GetString("filePathFormat"),
  51. SizeLimit = Config.GetInt("fileMaxSize"),
  52. UploadFieldName = Config.GetString("fileFieldName")
  53. });
  54. break;
  55. case "listimage":
  56. action = new ListFileManager(context, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"));
  57. break;
  58. case "listfile":
  59. action = new ListFileManager(context, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"));
  60. break;
  61. case "catchimage":
  62. action = new CrawlerHandler(context);
  63. break;
  64. default:
  65. action = new NotSupportedHandler(context);
  66. break;
  67. }
  68. action.Process();
  69. }
  70. public bool IsReusable
  71. {
  72. get
  73. {
  74. return false;
  75. }
  76. }
  77. }