简体   繁体   English

在Liferay中上传和显示数据库中的图像

[英]upload and display images from database in liferay

I have written code for upload and display of images in java. 我已经编写了用于用Java上传和显示图像的代码。 I am using liferay. 我正在使用liferay。 Since to my knowledge liferay service.xml doesnt have Blob I used an alternative way by modifying the portlet-model-hints.xml file. 据我所知liferay service.xml没有Blob我通过修改portlet-model-hints.xml文件使用了另一种方法。 Initially the field for storing image was made string which was changed to Clob in the above mentioned file. 最初,用于存储图像的字段为字符串,该字符串在上述文件中更改为Clob After building services it becomes longtext. 建立服务后,它变成了长文本。 I stored the images as longtext and when I try to display the text is displayed. 我将图像存储为长文本,并在尝试显示文本时显示。 How should I try to display the pics stored in the mysql database? 我应该如何显示存储在mysql数据库中的图片?

Create a hook that renders the value of the field as a image (transmute backwards from what you did to store it as text in the first place) 创建一个将字段的值呈现为图像的钩子(从最初存储为文本的位置向后转换)

you should check out the liferay jackrabit configuration, maybe it can help you storing the images in the db in the first place 您应该检查一下liferay jackrabit配置,也许它可以帮助您首先将图像存储在数据库中

I was looking at service.xml related to document library contents ( see online here ), and... 我正在查看与文档库内容相关的service.xml在此处在线查看 ),并且...

...
<column name="repositoryId" type="long" />
<column name="path" type="String" />
<column name="version" type="String" />
<column name="data" type="Blob" />
...

So it has Blob type. 因此它具有Blob类型。
I hope this helps you. 我希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM