在线Word编辑-OnlyOffice开源框架
介绍
社区版允许您在本地服务器上安装ONLYOFFICE Docs,并将在线编辑器与ONLYOFFICE协作平台或其他流行系统集成。
ONLYOFFICE Docs 是一个在线办公套件,包括文本、电子表格和演示文稿的查看器和编辑器,完全兼容 Office Open XML 格式:.docx、.xlsx、.pptx,并支持实时协作编辑。文章来源:https://www.toymoban.com/news/detail-525777.html
安装onlyoffice镜像
# 将数据存储在容器外部
mkdir -p /app/onlyoffice/DocumentServer/logs
chmod 400 /app/onlyoffice/DocumentServer/logs
# onlyoffice/documentserver社区服务版本
# onlyoffice/documentserver-de 为开发版本:里面内置了rabbitmq、redis、nginx等必要的服务
docker pull onlyoffice/documentserver
docker run -i -t -d -p -e TZ="Asia/Shanghai" 8888:80 --restart=always -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data -v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice -v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql -e JWT_SECRET=my_jwt_secret onlyoffice/documentserver
后端仅需提供两个接口
- 接口1:返回文件链接和md5
- 文件保存回调接口
官网示例:
public class IndexServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter writer = response.getWriter();
Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
String body = scanner.hasNext() ? scanner.next() : "";
JSONObject jsonObj = (JSONObject) new JSONParser().parse(body);
if((long) jsonObj.get("status") == 2)
{
String downloadUri = (String) jsonObj.get("url");
URL url = new URL(downloadUri);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
InputStream stream = connection.getInputStream();
File savedFile = new File(pathForSave);
try (FileOutputStream out = new FileOutputStream(savedFile)) {
int read;
final byte[] bytes = new byte[1024];
while ((read = stream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
}
connection.disconnect();
}
writer.write("{\"error\":0}");
}
}
参考 地址
官网安装说明
onlyoffice+vue实现在线预览在线编辑
官网使用说明文章来源地址https://www.toymoban.com/news/detail-525777.html
到了这里,关于在线Word编辑-OnlyOffice开源框架的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!