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的默 ...
随机推荐
- zabbix对数据盘磁盘容量进行监控
示例将数据盘挂载到 /mnt目录 , 对 /mnt目录进程容量监控 item 添加对 /mnt 目录的监控项 tragger 添加触发项 这样完成对一个数据盘磁盘容量的监控
- .net完整的图文验证
摘自:http://blog.csdn.net/durongjian/article/details/4336380 一.创建ValidaeCode类库工程: 1.创建ValidaeCode类库工程, ...
- 标头“Vary:Accept-Encoding”指定方法[转]
现在的新浏览器都支持压缩了,因此如果网站启用了GZip,可以无需再指定“Vary: Accept-Encoding”标头,不过指定“Vary: Accept-Encoding”标头会有更高的保险,而它 ...
- ngx_lua学习笔记 -- capture + proxy 实现httpclient
题注 最近我在学习nginx的lua插件,发现结合nginx的异步io和lua的流程控制能力,还是有很丰富的想象空间的:几乎所有常见的http请求的处理逻辑都能搞定,诸如查查数据库,访问一下memca ...
- GO语言学习 ---nil
nil是什么 相信写过Golang的程序员对下面一段代码是非常非常熟悉的了: if err != nil { // do something.... } 当出现不等于nil的时候,说明出现某些 ...
- Python expandtabs() 方法
描述 expandtabs() 方法把字符串中的 tab 符号('\t')转为空格,tab 符号('\t')默认的空格数是 8. 从头开始数,数到第一个\t正好为8个空格,不足则补空格,如果还有\t, ...
- spring 多线程
http://blog.csdn.net/chszs/article/details/8219189 一.ThreadPoolTaskExecutor ThreadPoolTaskExecutor的配 ...
- django中处理文件上传文件
1 template模版文件uploadfile.html 特别注意的是,只有当request方法是POST,且发送request的<form>有属性enctype="multi ...
- Linux下的MongoDB安装配置以及基本用法示例
一 MongoDB的安装配置 (1)下载并安装: MongoDB安装包下载地址:https://www.mongodb.com/download-center [root@localhost src] ...
- gnome3增加自定义程序快捷方式
gnome3增加自定义程序快捷方式 1. 安装alacarte 在命令行输入下列命令安装alacarte程序 yum -y install alacarte 安装完毕后,在命令行输入下 ...