接入说明
本文档针对前端项目接入 kkFileView 的说明,并假设 kkFileView 的服务地址为:https://qt.cxcp.net/。
var url = 'http://127.0.0.1:8080/file/test.txt'; //要预览文件的访问地址
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(base64Encode(url)));
var originUrl = 'http://127.0.0.1:8080/filedownload?fileId=1'; //要预览文件的访问地址
var previewUrl = originUrl + '&fullfilename=test.txt'
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(Base64.encode(previewUrl)));
var url = 'ftp://127.0.0.1/file/test.txt'; //要预览文件的访问地址
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(Base64.encode(url)));
var originUrl = 'ftp://127.0.0.1/file/test.txt'; //要预览文件的访问地址
var previewUrl = originUrl + '?ftp.control.port=xx&ftp.username=xx&ftp.password=xx&ftp.control.encoding=(gbk,utf8等)'; //(为了安全强烈建议在配置中设置相关信息)
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(Base64.encode(previewUrl)));
var originUrl = 'http://127.0.0.1/file/test.txt'; //要预览文件的访问地址
var previewUrl = originUrl + '?basic.name=admin&basic.pass=123456'; //(为了安全强烈建议在配置中设置相关信息)
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(Base64.encode(previewUrl)));
主要事项:首先引入下面js 在把url转换成AES,注意前后端key必须相同(注意:JS下载到你接入服务器的网址)
<script src="https://qt.cxcp.net/js/crypto-js.js">
<script src="https://qt.cxcp.net/js/aes.js">
function aesEncrypt(encryptString, key) {
var key = CryptoJS.enc.Utf8.parse(key);
var srcs = CryptoJS.enc.Utf8.parse(encryptString);
var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
return encrypted.toString();
}
var key = "1234567890123456"; // AES秘钥16位数字
var url = "http://127.0.0.1/file/test.txt";
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(aesEncrypt(url, key))+'&encryption=aes');
密码参数:&filePassword=加密文件的密码
页码参数:&page=选择第几页预览
高亮参数:&highlightAll=关键字 突出显示
水印参数:&watermarkTxt=你的水印
重生参数:&forceUpdatedCache=true
分段参数:&pdfAutoFetch=true
跨域参数:&kkagent=true
加密缓存:&usePasswordCachet=true
秘钥参数:&key= 访问秘钥
主要事项:以上参数是把url转换成base64后面在添加
var url = 'http://127.0.0.1:8080/file/test.txt'
window.open('https://qt.cxcp.net/onlinePreview?url='+encodeURIComponent(base64Encode(url))+'&filePassword=123&page=1&highlightAll=kkfileview&watermarkTxt=kkfileview&pdfAutoFetch=false&kkagent=false&key=123');