On Thu, Aug 20, 2009 at 9:12 AM, Jukka Zitting<[email protected]> wrote:
> The recommended way to store images or in fact any kinds of binary
> files is to use the nt:file and nt:resource node types....
> ...And the JCR 1.0 code to create such a file is:
>
> InputStream stream = ...; // the binary image data
> Node parent = ...; // where you want to store the image
>
> Node image = parent.addNode("myimage.png", "nt:file");
> Node content = image.addNode("jcr:content", "nt:resource");
> content.setProperty("jcr:mimeType", "image/png");
> content.setProperty("jcr:lastModified", Calendar.getInstance());
> Value data = session.getValueFactory().createValue(stream);
> content.setProperty("jcr:data", data);
> parent.save();
I've been thinking for a while that a JCR utilities library that
encapsulates such things ("create a file from this InputStream",
"create child node with a unique name", ...) in JCR would be useful.
Is there a module in Jackrabbit for such general-purpose JCR
utilities? Or where should that go?
-Bertrand