Re: what is the best way of storing text+image documents in postgresql

From: Radosław Smogura <rsmogura(at)softperience(dot)eu>
To: Arash pajoohande <apajoohande(at)gmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: what is the best way of storing text+image documents in postgresql
Date: 2011-06-09 07:41:47
Message-ID: e2a58874cc3888048306bb2b77a2eb6e@mail.softperience.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 8 Jun 2011 14:43:16 +0430, Arash pajoohande wrote:
> hello
> i have a lot of files in microsoft word format. each file consists of
> text and images (other text formatting like font is not important).
> i want to store this documents in Postgresql, and documents must
> display on web page when corresponding user requests occurs.
>
> it seems theres 2 way to do that:
> 1. save .doc documents in bytea columns. and show them with a word
> reader in web page (disadvantage: it needs a proper .doc reader
> installed on user computer)
> 2. convert document to html format and store html code as string
> (disadvantage: images will remain in file system)
>
> what is your offer? any help highly would be appreciated
>
> thanks in advance
> arash

If you want to do 2. there is no problem your application should
display documents like this
/browswer/<document_id>/<start>.html

Then after conversion put all generated files in database, converted
document (start.html) should be relatively linked, if some browser will
call to load image big/my_logo.png, then it will do request
/browswer/<document_id>/html/big/my_logo.png

Your CGI/Servlet will capture every request after /browser, you have id
of document and requested file name passed in URL then do
SELECT content where doc_id=... and filename='....'

Caching, speed-uping, on demand generation, securing is on your side.

Regards,
Radek

In response to

Browse pgsql-general by date

  From Date Subject
Next Message pasman pasmański 2011-06-09 08:26:41 Re: plpgsql function with update and seeing changed data from outside during run
Previous Message Radosław Smogura 2011-06-09 07:32:38 Re: Best Practices - Securing an Enterprise application using JBOSS & Postgres