2016-02-10 70 views
0

我正在使用Webcenter網站12.2.1,並且我有一個關於具有虛榮網址的媒體模板的問題。 我的用戶希望爲某些媒體(如PDF或圖像或此類斑點)製作虛空網址。我可以爲基於文本的屬性(如javascript或css)執行此操作,但對於基於blob的屬性,我有點卡住了。關鍵是要做一個資產的虛榮URL,我必須使用一個模板。在模板中,如果我必須顯示文本,則不存在任何問題。對於blob,我可以獲取該屬性,但如果我想將結果作爲模板進行流式傳輸,而不調用Blob服務器URL,則我沒有任何可用的東西。Webcenter網站:圖片或PDF的虛榮網址

這裏是我使用的模板代碼:

<%@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> 

我已經嘗試過解決方法:重定向到團塊服務器,但問題是,那麼我不能直接使用的網址爲圖片< img src =「/ prettyUrl」>重定向不起作用。

有沒有人試過這樣做?

回答

1

通過Oracle社區找到解決方案:我必須使用控制器。

一個例子是在示例站點應用程序已經給出

的http:// <>:<> /網站/樣品/ blob_link_builder

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

編輯:從那時起,我使用一個不同的解決方案,我用blob的虛榮URL。我只需要使用AssetType創建一個適用於我的資產的blob屬性的虛空URL,而不是創建模板。這比用任何模板來顯示圖像或類似的東西要容易得多。