在 JCR 2 中将 inputStream 读入节点属性的正确方法是什么?

发布于 2024-08-28 01:44:10 字数 610 浏览 5 评论 0原文

在 JCR 1 中,您可以这样做:

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

但这在 JCR 2 中已被弃用,详细信息请参见 http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html #setProperty%28java.lang.String,%20java.io.InputStream%29

这表示我应该使用 node.setProperty(String, Binary) 但我没有看到任何方法将我的 inputStream 转换为二进制。谁能向我指出这方面的文档或示例代码?

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/Node.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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事与诗 2024-09-04 01:44:10
ValueFactory.createBinary(InputStream stream)

您可以通过 Repository.login() 返回的 Session 获取 ValueFactory

ValueFactory.createBinary(InputStream stream)

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

旧话新听 2024-09-04 01:44:10

Rob 回答后的一个提示,如果您想知道从哪里获取 ValueFactory,您可以使用:

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

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

node.getSession().getValueFactory().createBinary(inputStream)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文