Document compression

Hi Guys,

we have been working to integrate our document management application (php) into OP and after scratching my head as to why I couldn't get the contents of a pdf file to correctly encode to a downloadable document, I remembered Tony mentioning the document table has compressed data.

Can you relate the level at which compression occurs (pre/post db insertion) and method of retrieval.

Cheers,
Matt C

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: [OpenVPMS Developers] Document compression

Documents are compressed using "deflate" compression format prior to insertion into the database. This is done using the java.util.zip.DeflaterOutputStream class. On retrieval they are decompressed using java.util.zip.InflaterInputStream.

The relevant OpenVPMS class that performs the insertion and retrieval is AbstractDocumentHandler.

See http://www.openvpms.org/fisheye/browse/openvpms/archetypes/trunk/src/java/org/openvpms/archetype/rules/doc/AbstractDocumentHandler.java?r=2264

There probably should be another column in the documents table to indicate if the document is compressed, and the compression type.

-Tim

mpcosta@boroniavet.com.au wrote:

> Hi Guys, > > we have been working to integrate our document management application > (php) into OP and after scratching my head as to why I couldn't get > the contents of a pdf file to correctly encode to a downloadable > document, I remembered Tony mentioning the document table has > compressed data. > > Can you relate the level at which compression occurs (pre/post db > insertion) and method of retrieval. > > Cheers, > Matt C > _______________________________________________ > OpenVPMS Developers Mailing List > developers@lists.openvpms.org > http://lists.openvpms.org/mailman/listinfo/developers >

_______________________________________________ OpenVPMS Developers Mailing List developers@lists.openvpms.org http://lists.openvpms.org/mailman/listinfo/developers

RE: [OpenVPMS Developers] Document compression

Hi Matt,

Here is a link to some functions that may help you inflate and deflate the data in php. http://www.php.net/manual/en/function.gzdeflate.php

I note in the documentation that gzinflate may have problems with >2M files ?

Also deflate is a raw compression format that has no header information. This is why you cannot download the blob contents into a file and the open with applications like winzip etc.

Tim, do you think we should be using subclass ZipOutputStream instead of DeflateOutputStream. Would mean we could utilise standard zip libraries and data viewers and functions and open in standard zip viewers. Understand we would need a new column in document table to indicate format in order to support legacy data etc.

Cheers Tony

-----Original Message----- From: developers-bounces@lists.openvpms.org [mailto:developers-bounces@lists.openvpms.org]On Behalf Of Tim Anderson Sent: Friday, 12 December 2008 08:23 To: OpenVPMS Developers Mailing List Subject: Re: [OpenVPMS Developers] Document compression

Documents are compressed using "deflate" compression format prior to insertion into the database. This is done using the java.util.zip.DeflaterOutputStream class. On retrieval they are decompressed using java.util.zip.InflaterInputStream.

The relevant OpenVPMS class that performs the insertion and retrieval is AbstractDocumentHandler.

See http://www.openvpms.org/fisheye/browse/openvpms/archetypes/trunk/src/java/org/openvpms/archetype/rules/doc/AbstractDocumentHandler.java?r=2264

There probably should be another column in the documents table to indicate if the document is compressed, and the compression type.

-Tim

mpcosta@boroniavet.com.au wrote:

> Hi Guys, > > we have been working to integrate our document management application > (php) into OP and after scratching my head as to why I couldn't get > the contents of a pdf file to correctly encode to a downloadable > document, I remembered Tony mentioning the document table has > compressed data. > > Can you relate the level at which compression occurs (pre/post db > insertion) and method of retrieval. > > Cheers, > Matt C > _______________________________________________ > OpenVPMS Developers Mailing List > developers@lists.openvpms.org > http://lists.openvpms.org/mailman/listinfo/developers >

_______________________________________________ OpenVPMS Developers Mailing List developers@lists.openvpms.org http://lists.openvpms.org/mailman/listinfo/developers

_______________________________________________ OpenVPMS Developers Mailing List developers@lists.openvpms.org http://lists.openvpms.org/mailman/listinfo/developers

Compression

Thats a great help guys. I'll have a go and let you know how I go with the php functions Tony.

 

Is the COMPRESS/UNCOMPRESS mysql function not very good? It would mean you could keep your API layer independent of compression requirements?

 

Matt C

Compression success with php

That worked a treat Tony.

gzuncompress()

I just stick it in a my retrival script, add some headers for a forced download and ta-da...

 If I wanted to insert a document, what compression level should I be using (1-9)?

Are all mime types/documents compressed tho?

 

Matt

 

RE: [OpenVPMS Developers] Compression success with php

Hi Matt,

Thats good news.

To keep OpenVPMS database independent we don't utilise any specific database functions.

Every document added via the user interface is compressed into the longblob contents field.

Cheers Tony

-----Original Message----- From: developers-bounces@lists.openvpms.org [mailto:developers-bounces@lists.openvpms.org]On Behalf Of mpcosta@boroniavet.com.au Sent: Friday, 12 December 2008 11:50 To: developers@lists.openvpms.org Subject: [OpenVPMS Developers] Compression success with php

That worked a treat Tony. gzuncompress()

I just stick it in a my retrival script, add some headers for a forced download and ta-da...

Are all mime types/documents compressed tho?

Matt

_______________________________________________ OpenVPMS Developers Mailing List developers@lists.openvpms.org http://lists.openvpms.org/mailman/listinfo/developers

_______________________________________________ OpenVPMS Developers Mailing List developers@lists.openvpms.org http://lists.openvpms.org/mailman/listinfo/developers

Re: [OpenVPMS Developers] Document compression

_______________________________________________ OpenVPMS Developers Mailing List developers@lists.openvpms.org http://lists.openvpms.org/mailman/listinfo/developers

Syndicate content