jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: How to store text file into repository using jackrabbit
Date Wed, 23 Jun 2010 14:06:28 GMT
On Wed, Jun 23, 2010 at 15:23, Prasad Basutkar <prasad@e-novatetech.com> wrote:
>            I am using jackrabbit 2.1.0 and I wanted to store my text file
> into repository location , but  resNode.setProperty("jcr:data", new
> FileInputStream(new File("hi.txt"))) method is deprecated because of which I
> am not able to store text file into repository , can you please tell me how
> to store text file into repository.

AFAIK it is deprecated, but should still work. The proper replacement
is using the new javax.jcr.Binary:

    Binary binary = session.getValueFactory().createBinary(inputStream);
    try {
        content.setProperty(Property.JCR_DATA, binary);
    } finally {

If you add nt:file nodes, the might be easier to use the
JcrUtils.putFile() utility methods from the jackrabbit-commons library

[1] http://jackrabbit.apache.org/api/2.1/org/apache/jackrabbit/commons/JcrUtils.html#putFile(javax.jcr.Node,%20java.lang.String,%20java.lang.String,%20java.io.InputStream)
[2] http://jackrabbit.apache.org/api/2.1/org/apache/jackrabbit/commons/JcrUtils.html#putFile(javax.jcr.Node,%20java.lang.String,%20java.lang.String,%20java.io.InputStream,%20java.util.Calendar)


Alexander Klimetschek

View raw message