You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sascha Kulawik <sa...@kulawik.de> on 2002/07/26 22:07:26 UTC
Return BLOB Value
Hello,
I'm trying to implement a File-Upload / Download for a small Forum
written in Cocoon XSP.
Currently Ive no idea how to implement the FileDownload. The easiest way
for that would be to write the data to a mySQL Ressouce and read the
data because of Userpermissions and so on.
Is it possible, to returm plain BLOB Data from a Database to the User
for a Download ?
Is there a better way to implement that in Cocoon ?
Thank you very much,
Greetings,
Sascha
Re: Return BLOB Value
Posted by Jeroen ter Voorde <j....@home.nl>.
Return BLOB ValueYou can use a Reader to implement this (That's what i did).
(Stripped) Example:
public class Reader extends AbstractReader implements Poolable, Composable {
Request request = null;
Response response = null;
Context context = null;
ComponentManager manager = null;
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
context = ObjectModelHelper.getContext(objectModel);
request = ObjectModelHelper.getRequest(objectModel);
response = ObjectModelHelper.getResponse(objectModel);
}
public void generate() throws IOException, SAXException, ProcessingException {
try {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
// out is the outputstream to write your blob data to.
((OutputStream)out).write('The blob data');
}
} catch (Exception e) {
throw new ProcessingException("Error in reader: "+e);
}
}
public String getMimeType() {
return context.getMimeType(source.substring(source.lastIndexOf("/") + 1));
}
}
----- Original Message -----
From: Sascha Kulawik
To: cocoon-users@xml.apache.org
Sent: Friday, July 26, 2002 10:07 PM
Subject: Return BLOB Value
Hello,
I'm trying to implement a File-Upload / Download for a small Forum written in Cocoon XSP.
Currently Ive no idea how to implement the FileDownload. The easiest way for that would be to write the data to a mySQL Ressouce and read the data because of Userpermissions and so on.
Is it possible, to returm plain BLOB Data from a Database to the User for a Download ?
Is there a better way to implement that in Cocoon ?
Thank you very much,
Greetings,
Sascha