jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabián Mandelbaum <fmandelb...@gmail.com>
Subject Storing a file's content with JCR2.0
Date Wed, 02 Mar 2011 19:24:37 GMT
Hello, with JCR1.0, I've done something like this to store file
streams (the file's binary data itself):

node.setProperty("jcr:data", new AutoCloseInputStream(new

where AutoCloseInputStream is from Commons-IO.

I've read everywhere that I have to use the new Binary 'type' (it's
actually an Interface, so it's not instantiable) to store files now.
I've read everywhere how to READ the streams
(node.getProperty("jcr:data").getBinary().getStream()), but nowhere (I
could find at least...) how to WRITE the streams to the content
repository (that is, how to set the jcr:data property of the
nt:resource node of the nt:file node).

I've found out that with JackRabbit I can do the following:

Binary data = new BinaryImpl(new AutoCloseInputStream(new
node.setProperty("jcr:data", data);

which is great... except there's BinaryImpl, which is JackRabbit-specific.

Now, I don't think I'll ever use a different JCR2.0 repository
implementation, but I'd like to know how to store files in a way
that's repository implementation agnostic with JCR2.0 and JackRabbit
2.2.4 (the JCR 1.0 method was repository implementation agnostic, all
APIs used to store the binary values where from JCR 1.0 spec itself).

Any pointer to docs or examples regarding this are appreciated as much
as a concrete code example as an answer.


Fabián Mandelbaum
IS Engineer

View raw message