Esempio n. 1
0
        public static Handler GetHandler(string action, HttpContext context)
        {
            switch (action)
            {
            case AppConsts.Action.UploadImage:
                return(new UploadHandler(context, new UploadConfig
                {
                    AllowExtensions = EditorConfig.GetStringList("imageAllowFiles"),
                    UrlPrefix = EditorConfig.GetString("imageUrlPrefix"),
                    PathFormat = EditorConfig.GetString("imagePathFormat"),
                    SizeLimit = EditorConfig.GetInt("imageMaxSize"),
                    UploadFieldName = EditorConfig.GetString("imageFieldName")
                }));

            case AppConsts.Action.UploadScrawl:
                return(new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = new string[] { ".png" },
                    UrlPrefix = EditorConfig.GetString("scrawlUrlPrefix"),
                    PathFormat = EditorConfig.GetString("scrawlPathFormat"),
                    SizeLimit = EditorConfig.GetInt("scrawlMaxSize"),
                    UploadFieldName = EditorConfig.GetString("scrawlFieldName"),
                    Base64 = true,
                    Base64Filename = "scrawl.png"
                }));

            case AppConsts.Action.UploadVideo:
                return(new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = EditorConfig.GetStringList("videoAllowFiles"),
                    UrlPrefix = EditorConfig.GetString("videoUrlPrefix"),
                    PathFormat = EditorConfig.GetString("videoPathFormat"),
                    SizeLimit = EditorConfig.GetInt("videoMaxSize"),
                    UploadFieldName = EditorConfig.GetString("videoFieldName")
                }));

            case AppConsts.Action.UploadFile:
                return(new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = EditorConfig.GetStringList("fileAllowFiles"),
                    UrlPrefix = EditorConfig.GetString("fileUrlPrefix"),
                    PathFormat = EditorConfig.GetString("filePathFormat"),
                    SizeLimit = EditorConfig.GetInt("fileMaxSize"),
                    UploadFieldName = EditorConfig.GetString("fileFieldName")
                }));

            case AppConsts.Action.ListImage:
                return(new ListFileManager(context, EditorConfig.GetString("imageManagerListPath"), EditorConfig.GetStringList("imageManagerAllowFiles")));

            case AppConsts.Action.ListFile:
                return(new ListFileManager(context, EditorConfig.GetString("fileManagerListPath"), EditorConfig.GetStringList("fileManagerAllowFiles")));

            case AppConsts.Action.CatchImage:
                return(new CrawlerHandler(context));

            default:
                return(new NotSupportedHandler(context));
            }
        }
Esempio n. 2
0
        public void Index()
        {
            string  action  = Request.Params["action"];
            Handler hand    = null;
            var     context = HttpContext;

            switch (action)
            {
            case "config":
                hand = new ConfigHandler(context);
                break;

            case "uploadimage":
                hand = new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = EditorConfig.GetStringList("imageAllowFiles"),
                    PathFormat      = EditorConfig.GetString("imagePathFormat"),
                    SizeLimit       = EditorConfig.GetInt("imageMaxSize"),
                    UploadFieldName = EditorConfig.GetString("imageFieldName")
                });
                break;

            case "uploadscrawl":
                hand = new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = new string[] { ".png" },
                    PathFormat      = EditorConfig.GetString("scrawlPathFormat"),
                    SizeLimit       = EditorConfig.GetInt("scrawlMaxSize"),
                    UploadFieldName = EditorConfig.GetString("scrawlFieldName"),
                    Base64          = true,
                    Base64Filename  = "scrawl.png"
                });
                break;

            case "uploadvideo":
                hand = new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = EditorConfig.GetStringList("videoAllowFiles"),
                    PathFormat      = EditorConfig.GetString("videoPathFormat"),
                    SizeLimit       = EditorConfig.GetInt("videoMaxSize"),
                    UploadFieldName = EditorConfig.GetString("videoFieldName")
                });
                break;

            case "uploadfile":
                hand = new UploadHandler(context, new UploadConfig()
                {
                    AllowExtensions = EditorConfig.GetStringList("fileAllowFiles"),
                    PathFormat      = EditorConfig.GetString("filePathFormat"),
                    SizeLimit       = EditorConfig.GetInt("fileMaxSize"),
                    UploadFieldName = EditorConfig.GetString("fileFieldName")
                });
                break;

            case "listimage":
                hand = new ListFileManager(context, EditorConfig.GetString("imageManagerListPath"), EditorConfig.GetStringList("imageManagerAllowFiles"));
                break;

            case "listfile":
                hand = new ListFileManager(context, EditorConfig.GetString("fileManagerListPath"), EditorConfig.GetStringList("fileManagerAllowFiles"));
                break;

            case "catchimage":
                hand = new CrawlerHandler(context);
                break;

            default:
                hand = new NotSupportedHandler(context);
                break;
            }
            hand.Process();
        }