首页 > 解决方案 > 将 Dropbox 视频添加到 html 网页

问题描述

我正在尝试将来自 Dropbox Api (Java) 的视频文件 (mp4) 与 thymeleaf 集成到我的 spring-made 网站。但是,我无法访问视频文件的链接。我的想法是——>

<html>
<main>
    <h2 th:text="${videoName}"></h2>
    <video>
        <source src="*/some url from the dropbox api to visualize the video\*"/>
    </video>
    <p th:text="${videoDescription}"></p>
    ...
</main>
</html>

谢谢!

标签: javahtmlspringthymeleafdropbox-api

解决方案


我找到了。我必须嵌入共享文件链接并将 dl=0 替换为 raw=1。

<html>
<main>
    <h2 th:text="${videoName}"></h2>
    <iframe th:src="${dropboxUrl}"></iframe>
    <p th:text="${videoDescription}"></p>
    ...
</main>
</html>

可以通过 ListSharedLinkResult 接收原始共享链接。

ListSharedLinksResult listSharedLinksResult = dbxClientV2.sharing().listSharedLinksBuilder().withPath(dropboxPath).withDirectOnly(true).start();
String result = listSharedLinksResult.getLinks().get(0).getUrl();

推荐阅读