【发布时间】: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