【问题标题】:Webcenter Sites : Vanity URLs for images or PDF网站中心站点:图像或 PDF 的虚荣 URL
【发布时间】:2016-02-10 07:42:27
【问题描述】:

我正在使用 Webcenter Sites 12.2.1,我有一个关于为带有虚 URL 的媒体模板的问题。 我的用户希望为某些媒体(如 PDF 或图像或此类 blob)提供虚 URL。对于基于文本的属性,例如 javascripts 或 css,我可以这样做,但对于基于 blob 的属性,我有点卡住了。关键是要为资产创建虚 URL,我必须使用模板。如果我必须在模板中显示文本,则没有问题。对于 blob,我可以获得属性,但如果我想将结果作为模板流式传输而不调用 blob 服务器 URL,我将得不到任何可用的东西。

这是我使用的模板的代码:

<%@page import="java.io.InputStream"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%>
<%@ page import="com.fatwire.system.*"%>
<%@ page import="com.fatwire.assetapi.data.*"%>
<%@ page import="com.fatwire.assetapi.query.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.openmarket.xcelerate.asset.*"%>
<%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"%>
<%@ taglib prefix="ics" uri="futuretense_cs/ics.tld"%>
<%@ taglib prefix="fragment" uri="futuretense_cs/fragment.tld"%>
<%@ taglib prefix="render" uri="futuretense_cs/render.tld"%>
<%@ taglib prefix="asset" uri="futuretense_cs/asset.tld"%>
<cs:ftcs>
<%
Session ses = SessionFactory.getSession();
AssetDataManager mgr =(AssetDataManager) ses.getManager( AssetDataManager.class.getName() );
AssetId id = new AssetIdImpl( "Content_R",new Long(ics.GetVar("cid")));
List attrNames = new ArrayList();
attrNames.add( "imagefile" );
AssetData data = mgr.readAttributes( id, attrNames );
AttributeData attrDataSource = data.getAttributeData( "imagefile" );
BlobObject fileObj = (BlobObject)attrDataSource.getData();
File file = new File(fileObj.getFoldername() + fileObj.getFilename());
InputStream in = new FileInputStream(file);
byte[] bytes = new byte[2048];
int bytesRead;
ServletOutputStream out2 = response.getOutputStream();
while ((bytesRead = in.read(bytes)) != -1) {
    out2.write(bytes, 0, bytesRead);
}
in.close();
%>

</cs:ftcs>

我已经尝试过一种解决方法:重定向到 blob 服务器,但问题是我不能直接使用 url 作为图像 重定向不起作用。

有人试过吗?

【问题讨论】:

    标签: vanity-url webcenter-sites


    【解决方案1】:

    通过 Oracle 社区找到了一个解决方案:我必须使用控制器。

    示例站点应用程序中已经给出了一个示例

    http://:/sites/samples/blob_link_builder

    http://docs.oracle.com/middleware/1221/wcs/develop/GUID-C8899CBC-2EC1-4A25-A887-F8B9A868084D.htm#WBCSD8200

    编辑:从那以后,我使用了不同的解决方案,我使用虚 URL 作为 blob。我没有做模板,而是使用 AssetType,而是创建一个虚 URL,它将应用于我的资产的 blob 属性。这比做任何模板来显示图像或类似的东西要容易得多。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 1970-01-01
      • 2017-07-20
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多