如何以编程方式获取文档库内容的下载URL [英] How to obtain the download url for a document library content programmatically
问题描述
我的文档库中有几个内容(图像,文档,视频...),我想以编程方式获取它们的下载URL,因此可以在自定义portlet的jsp上显示它们.
I have several contents in my document library (images, documents, videos...) and I want to obtain the download url for each of them programmatically, so I can show them on a jsp in a custom portlet.
调查中,我发现此页面包含可能的解决方案: https://www.liferay.com/community/forums/-/message_boards /message/11073293 但我对此感到不满意,因为这意味着需要使用多个参数来手动构建url.
Investigating, I have found this page with a possible solution: https://www.liferay.com/community/forums/-/message_boards/message/11073293 but I'm not comfortable with it, since it implies building the url manually with several parameters.
我想知道是否有更好的方法("Liferay方法")来完成此操作.
I would like to know if there is a better way ("Liferay way") to do this.
推荐答案
我恐怕是那条生命线:-).
I am afraid but that is the liferay way :-).
如果您仍然需要更多确认,请查看 DLUtil#getPreviewURL
方法.
If you still need more confirmation check out source code of the DLUtil#getPreviewURL
method.
liferay的Documents & Media portlet
和Document and Media display portlet
已使用此方法.您还可以签出有关这些Portlet如何使用上述方法的JSP源
This method has been used by liferay's Documents & Media portlet
and Document and Media display portlet
. Also you can check-out the JSP source as to how these portlets use the above method /portal-web/docroot/html/portlet/document_library/action/download.jspf
.
PS:
您可以使用FileEntry
%29>静态方法.
P.S.:
You can convert DLFileEntry
to FileEntry
with this static method.
这篇关于如何以编程方式获取文档库内容的下载URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!