开发者

What's the correct way to read an inputStream into a node property in JCR 2?

In JCR 1 you could do:

final InputStream in = zip.getInputStream(zip.getEntry(zipEntryName));
node.setProperty(JcrConstants.JCR_CONTENT, in);

But that's deprecated in JCR 2 as detailed at http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/Nod开发者_开发问答e.html#setProperty%28java.lang.String,%20java.io.InputStream%29

That says I should be using node.setProperty(String, Binary) but I don't see any way to turn my inputStream into a Binary. Can anyone point me to docs or example code for this?


ValueFactory.createBinary(InputStream stream)

You get the ValueFactory through the Session returned by Repository.login()


Just a tip after Rob's answer, if you wondered where to get ValueFactory from, you can use:

node.getSession().getValueFactory().createBinary(inputStream)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜