cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@informatik.tu-darmstadt.de>
Subject Re: How to show files from database / DatabaseReader problem
Date Sun, 30 Nov 2003 12:22:36 GMT
Joerg Heinicke wrote:
> On 30.11.2003 02:20, O.Vobejda@sh.cvut.cz wrote:
> 
>> Hi,
>>
>> I have a big problem with Database reader. I'd like to make a common 
>> stuff - in the database I are stored binary files (table structure 
>> looks: (id, content, filename, mimetype) and I'd like to map url 
>> "file/234" on the accordant file. Remind, that in the database can be 
>> stored everything possible stuff (images, documents etc.).
>>
>> I tried to use databasereader. All works ok, until I'd like to change 
>> mime-type to appropriate mime-type stored in the database. For this 
>> purpose should be used parameter "content-type". But it doesn't work 
>> and doesn't return regular value from database. It just returns that 
>> string, I inserted with parameter. It is correct? If so, how can I 
>> solve my problem? I tried this solution:
>>
>> Usual select: "select content, mimetype from files where id=123 and 
>> status=1"
>>
>> Using databasereader:
>>
>> <map:match pattern="files/*">
>>   <map:read type="databasereader" src="{1}" mime-type="plain/text">
>>     <map:parameter name="table" value="files"/>
>>     <map:parameter name="image" value="content"/>
>>     <map:parameter name="key" value="id"/>
>>     <map:parameter name="where" value="status=1"/>

Please have a look at the javadocs. content-type sets a fixed mimetype
for the generated data while type-column specifies the column that
stores the mimetype. So change it to

        <map:parameter name="type-column" value="mimetype"/>

BTW the upload sample in the databases block demos this usage.

>>   </map:read>
>> </map:match>
>>
>> But that doesn't work. So how to solve that? Or do you know some 
>> alternative ways?
> 
> 
> If you have a look at the source code
> http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/reading/DatabaseReader.java?annotate=1.4#400

> 
> you will see that the mime-type is not taken from database, but the 
> parameter value itself, i.e. 'mimetype'. If that's useful or not - I 
> don't know. Maybe you can patch the databasereader.

No need to -- that has already been done :-)

	Chris.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message