Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Behzad Gadimi
How to store an image in database
February 19, 2013 6:03 AM
Answer

Behzad Gadimi

Rank: Junior Member

Posts: 36

Join Date: March 8, 2011

Recent Posts

Hi,
what type should I choose for an image in service.xml file so I can store it in database? (I have choosed MySQL)

thanks in advance ...
Gnaniyar Zubair
RE: How to store an image in database
February 19, 2013 6:10 AM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 622

Join Date: December 19, 2007

Recent Posts

You can use BLOB data type in service.xml .

see the service.xml for Document Media Portlet[/b in portal source.

liferay-portal-src-6.1.1-ce-ga2\portal-impl\src\com\liferay\portlet\documentlibrary\service.xml
Behzad Gadimi
RE: How to store an image in database
February 19, 2013 6:27 AM
Answer

Behzad Gadimi

Rank: Junior Member

Posts: 36

Join Date: March 8, 2011

Recent Posts

thanks ...
I am using liferay version 6.0.6.
Is it working in this version?
Gnaniyar Zubair
RE: How to store an image in database
February 19, 2013 6:38 AM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 622

Join Date: December 19, 2007

Recent Posts

I think BLOB is supported for version 6.0.6 also. Please check the source code.
Behzad Gadimi
RE: How to store an image in database
February 19, 2013 6:49 AM
Answer

Behzad Gadimi

Rank: Junior Member

Posts: 36

Join Date: March 8, 2011

Recent Posts

Could you explain a bit about how to use it?
I couldn't find it in my source for 6.0.6.

thanks again
Gnaniyar Zubair
RE: How to store an image in database
February 19, 2013 6:53 AM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 622

Join Date: December 19, 2007

Recent Posts

Have you downloaded Liferay portal source for 6.0.6..?

then check BLOB type in service.xml file from this location
liferay-portal-src-6.0.6\portal-impl\src\com\liferay\portlet\documentlibrary\service.xml
Behzad Gadimi
RE: How to store an image in database
February 19, 2013 8:05 AM
Answer

Behzad Gadimi

Rank: Junior Member

Posts: 36

Join Date: March 8, 2011

Recent Posts

Yes, I have downloaded it, but in that service.xml, there is no BLOB.
Is that possible to use plugin-sdk 6.1.1 and portal 6.0.6 (not 6.1.1) ?
Gnaniyar Zubair
RE: How to store an image in database
February 19, 2013 2:09 PM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 622

Join Date: December 19, 2007

Recent Posts

No you cannot use different versions for Plugin SDK and Server.

You can achieve this in 6.0.6 also. In Service.xml, just mention as String for that file field. then manually you can change the datatype as BLOB or CLOB in portlet-model-hints.xml'

Please see our blog : vforLiferay
Hitoshi Ozawa
RE: How to store an image in database
February 19, 2013 2:26 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Check the following thread. There's not clob nor blob type in service builder. You'll have to specify it in portlet-model-hints.xml so they will be converted during build.

https://www.liferay.com/community/forums/-/message_boards/message/6225245
Gnaniyar Zubair
RE: How to store an image in database
February 19, 2013 2:49 PM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 622

Join Date: December 19, 2007

Recent Posts

No. We can give the Blob type in service.xml in 6.x version of liferay .

You can see service.xml of document library :

<column name="data" type="Blob" />
Hitoshi Ozawa
RE: How to store an image in database
February 19, 2013 3:19 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Liferay is using it as a String instead of Binary object as in database type.

Following may help:
http://www.liferay.com/community/forums/-/message_boards/message/91027
Gnaniyar Zubair
RE: How to store an image in database
February 19, 2013 9:49 PM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 622

Join Date: December 19, 2007

Recent Posts

Hi Hitoshi Ozawa,

I strongly disagree with your statement.

If we give type="Blob" in service.xml, it will create a BLOB datatype only from Liferay 6.x versions.

- Gnaniyar Zubair
Behzad Gadimi
RE: How to store an image in database
February 21, 2013 4:20 AM
Answer

Behzad Gadimi

Rank: Junior Member

Posts: 36

Join Date: March 8, 2011

Recent Posts

Hitoshi Ozawa:
Check the following thread. There's not clob nor blob type in service builder. You'll have to specify it in portlet-model-hints.xml so they will be converted during build.

https://www.liferay.com/community/forums/-/message_boards/message/6225245



what is the maximum image size that can be stored in CLOB filed?
what is max-length in this example?


thanks a lot ...
Seeya S Kudtarker
RE: How to store an image in database
March 19, 2013 2:43 AM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

Sorry fro interupting the thread here.
I tried the approach mentioned in:
http://vforliferay.blogspot.in/2010/12/fileupload-using-servicexml-file.html

Even when i try to deploy the longtext remains as long text in the database and it is not changed to clob after deploying.
Also since it remains longtext, when I try to display the images after uploading I get long string of text characters.

How should I ensure that my image which was uploaded in database is displayed?
Also why am I not able to convert text to clob even after buildong services ?