CKFinder 自定义文件路径扩展ConfigurationPathBuilder
CKFinder 自定义文件路径扩展ConfigurationPathBuilder
打开config.xml当中可以看到如下配置
<basePathBuilderImpl>com.ckfinder.connector.configuration.ConfigurationPathBuilder</basePathBuilderImpl>
打开这个类的源代码
/*
* CKFinder
* ========
* http://cksource.com/ckfinder
* Copyright (C) 2007-2014, CKSource - Frederico Knabben. All rights reserved.
*
* The software, this file and its contents are subject to the CKFinder
* License. Please read the license.txt file before using, installing, copying,
* modifying or distribute this file or part of its contents. The contents of
* this file is part of the Source Code of CKFinder.
*/
package com.ckfinder.connector.configuration; import javax.servlet.http.HttpServletRequest; import com.ckfinder.connector.utils.PathUtils; /**
* Path builder that creates default values of baseDir and baseURL.
*/
public class ConfigurationPathBuilder extends DefaultPathBuilder { /**
* Gets configuration value of baseUrl. When config value is not set, then
* return default value.
*
* @param request request
* @return default baseDir value
*/
@Override
public String getBaseUrl(final HttpServletRequest request) {
String baseURL = null;
try {
IConfiguration conf = ConfigurationFactory.getInstace().getConfiguration();
baseURL = conf.getBaseURL();
} catch (Exception e) {
baseURL = null;
}
if (baseURL == null || baseURL.equals("")) {
baseURL = super.getBaseUrl(request);
} return PathUtils.addSlashToBeginning(PathUtils.addSlashToEnd(baseURL));
} /**
* Gets configuration value of baseDir. When config value is not set, then
* return default value.
*
* @param request request
* @return default baseDir value
*/
@Override
public String getBaseDir(final HttpServletRequest request) {
String baseDir = null;
try {
IConfiguration conf = ConfigurationFactory.getInstace().getConfiguration();
baseDir = conf.getBaseDir();
} catch (Exception e) {
baseDir = null;
}
if (baseDir == null || baseDir.equals("")) {
return super.getBaseDir(request);
} else {
return baseDir;
}
}
}
一共俩个方法,一个是获取资源URL的,一个是获取服务器端文件路径的,所以我们复写这俩个方法实现我们自己的逻辑就可以了。
public class MyConfigurationPathBuilder extends ConfigurationPathBuilder {
private String getCustomPath(HttpServletRequest request) {
return request.getSession().getAttribute("bathPath").toString();
//return "EP/";
}
/**
* Gets configuration value of baseUrl. When config value is not set, then
* return default value.
*
* @param request request
* @return default baseDir value
*/
@Override
public String getBaseUrl(final HttpServletRequest request) {
return super.getBaseUrl(request)+ getCustomPath(request);
}
/**
* Gets configuration value of baseDir. When config value is not set, then
* return default value.
*
* @param request request
* @return default baseDir value
*/
@Override
public String getBaseDir(final HttpServletRequest request) {
return super.getBaseDir(request) + getCustomPath(request);
}
}
CKFinder 自定义文件路径扩展ConfigurationPathBuilder的更多相关文章
- RocketMQ 自定义文件路径
一 .1. 修改store路径2. 修改logs路径3. 修改rmq_bk_gc.log路径4. 修改rmq_srv_gc.log路径二 .1. 获取正确的rocketmq 源码2. 地址:https ...
- C# 截取带路径的文件名字,扩展名,等等 的几种方法
C#对磁盘IO操作的时候,经常会用到这些,路径,文件,文件名字,文件扩展名. 之前,经常用切割字符串来实现, 可是经常会弄错. 尤其是启始位置,多少个字节,经常弄晕. 下面这种方法貌似比较简便: st ...
- 从字符串总分离文件路径、命名、扩展名,Substring(),LastIndexOf()的使用;替换某一类字符串,Replace()的用法
一:从字符串总分离文件路径.命名.扩展名,上图 二:代码 using System; using System.Collections.Generic; using System.ComponentM ...
- python学习笔记(自定义库文件路径)
博主最近在弄接口自动化.主要是基于python自带的unittest框架.包括 Pubilc模块定义所有接口. Main模块根据业务需求重新封装接口便于测试. config文件导入测试业务的固定参数. ...
- android自定义camera以及uri和文件路径之间的转换
相对直接调用系统的camera,这种方法使用得相对还少一些.根据api文档,步骤如下: 定义一个预览类 可以参照<android高薪之路>这本书上面,有这种方法的一种完整实现 而对应的ac ...
- 修改CKFinder上传路径
一.CKFinder的若干问题 1.单独使用 ckfinder从原fckeditor分离出来以后可以单独使用,通常我习惯于在工具栏中添加ckfinder.dll,这样以后要使用ckfinder直接从工 ...
- C# 自定义文件图标 双击启动 (修改注册表)
程序生成的自定义文件,比如后缀是.test 这种文件怎么直接启动打开程序,并打开本文件呢 1.双击打开 2.自定义的文件,有图标显示 3.自定义的文件,点击右键有相应的属性 后台代码:(如何在注册表中 ...
- Spring配置文件详解 - applicationContext.xml文件路径
spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码 org.springframework.web.context.Cont ...
- Spring配置文件详解 – applicationContext.xml文件路径
Spring配置文件详解 – applicationContext.xml文件路径 Java编程 spring的配置文件applicationContext.xml的默 ...
随机推荐
- mysql sleep连接太多怎么办
摘要:interactive_timeout和wait_timeout参数对sleep连接的影响 interactive_timeout 参数含义:服务器关闭交互式连接前等待活动的秒数.交互式客户端定 ...
- ios block常见的错误(二)——循环引用
这篇博文继续block的常见错误——循环引用. 循环引用是很多初学者不能察觉的,其产生的原因,是block中的代码会对对象进行强引用. 读者请阅读示例代码1,并思考示例代码1所创建的对象能否被正常销毁 ...
- Matlab调用返回游标的存储过程的分析和处理
2.Matlab调用Oracl带游标参数输出的存储过程 笔者也是将工作之中遇到的问题进行了搜集与整理,才完成该文的编写,希望能帮助到有需要的朋友. 2.1.PLSQL中的存储过程 PROCEDURE ...
- nginx error: upstream prematurely closed connection while reading response header from upstream
本篇文章由:http://xinpure.com/nginx-error-upstream-prematurely-closed-connection-while-reading-response-h ...
- 学习JUnit
一.为什么测试很重要? 塑造系统的设计.我们知道输入和输出应该是什么样的,但是我们需要创建什么对象来做到这一点呢?代码应该塑造成什么样的"形状"?编写测试可以让我们知道应该创建什么 ...
- 【LeetCode】46. Permutations (2 solutions)
Permutations Given a collection of numbers, return all possible permutations. For example,[1,2,3] ha ...
- 【LeetCode】127. Word Ladder
Word Ladder Given two words (start and end), and a dictionary, find the length of shortest transform ...
- 【java设计模式】之 责任链(chain of resposibility)模式
责任链模式,顾名思义,就是一条链.这个链到底是怎么运行的呢?它主要是将能够处理同一类请求的对象连成一条链,所提交的请求沿着链传递,链上的对象逐个判断是否有能力处理该请求,如果能则处理,如果不能则传递给 ...
- 'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.'
产生这个错误的原因是,StaticResource必须先定义再引用,但是DynamicResource就没有这个限制,为避免这个错误出现,可将StaticResource的定义放在Window.xam ...
- WinDBG 常用命令表[转]
启动, 附加进程, 执行和退出(Starting, Attaching, Executing and Exiting) ======================= Start -> Al ...