使用Cloudreve的时候一直苦于不能在线预览,微软的预览服务也用不了
看到好多文档预览的服务,价格很贵 正好用的腾讯云COS,无意中看到腾讯云有文档转 HTML 功能
先看价格,价格第一位:
为什么要整这一步骤呢,因为Cloudreve把文件url转码了,直接访问不了,整个文件跳转一下,其实换个思路放到其他地方只要能打开html解码后跳转一下也可以了,这样网址更简洁一点
怎么命名文件都可以,代码不需要改动,我的是
https://储存桶名.cos-website.ap-区域.myqcloud.com/Documentpreview/index.html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document preview</title>
</head>
<body>
</body>
<script>
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
let Gotoiturl = decodeURIComponent(GetQueryString("url"))
//解码Cloudreve输出的文件url
window.location.replace(Gotoiturl + '?ci-process=doc-preview&dstType=html&htmlwaterword=Y2Npem0=&htmlhorizontal=100&htmlvertical150')
//跳转到文档预览地址,参数:https://cloud.tencent.com/document/product/436/54059
//记得把htmlwaterword参数(base64)改掉
</script>
</html>
参数什么的自己改就行了
https://储存桶名.cos.ap-区域.myqcloud.com/Documentpreview/index.html?url={$src}
在你的文件网址后面加上?url={$src}
😝
参考文档:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。