Hello,
I am hoping someone can help me with getting binary data out of a jackrabbit repository. I seem to be having some issues with that in an application I am trying to work with.

I can get data into the system with:

               Node root = session.getRootNode();
Node fileNode = root.addNode(file.getOriginalFilename(), "nt:file");
           Node resNode = fileNode.addNode("jcr:content", "nt:resource");
           resNode.setProperty("jcr:mimeType", file.getContentType());
           resNode.setProperty("jcr:encoding", "");
resNode.setProperty("jcr:data", new FileInputStream(tempFile.getAbsolutePath()));
           Calendar lastModified = Calendar.getInstance();
           resNode.setProperty("jcr:lastModified", lastModified);
           session.save();

This seems to work fine for getting files into the system and I can reliably get them out with:

           Node mroot = session.getRootNode();
           Node root = mroot.getNode("${nodeName}/jcr:content");
response.contentType = root.getProperty("jcr:mimeType").getString() response.outputStream << root.getProperty("jcr:data").getString()

for any text based files. However, whenever I try to do this with an image or PDF the file end up corrupted. I assume the last .getString() is doing bad things (converting my binary to string). - Am I missing a flag I need to set when sending a file up to the system that tells it is binary? - Is jackrabbit doing a base64 serialization/deserialization behinds the scenes?
- Is there same way to get the raw binary from the jcr:data node?

If it makes any difference this is running in a spring environment and I am letting spring set things up. For text, it's all working fine.. just need it to do the same for binary.
Thanks!
Doug



Reply via email to