jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Delacretaz <bdelacre...@apache.org>
Subject JCR utilities library (was: how to store images into jackrabbit repository)
Date Thu, 20 Aug 2009 07:19:26 GMT
On Thu, Aug 20, 2009 at 9:12 AM, Jukka Zitting<jukka.zitting@gmail.com> 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

Mime
View raw message