You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by John Logan <Jo...@texture.com> on 2017/03/22 15:50:08 UTC
Writing a Sling content via output stream as opposed to
Hehe, more questions...
When I'm writing content to resources, I've been using
ValueFactory to wrap an InputStream, and then setting
the jcr:data property of my content resource, and this
works fine.
I have one use case (a preexisting storage abstraction
layer) where I need to write a resource by getting an
OutputStream for the resource, akin to the way
java.nio.file.Files.newOutputStream() works.
Does the Sling Framework provide any way to do this?
I found nothing in either the JCR or the Sling docs, so
I'm planning to create a ResourceOutputStream that
derives from PipedOutputStream and creates a
copy thread, and PipedInputStream to plug into the
Binary value. If there's already something that supports
this way of writing, I'd prefer to use that though.
Thanks once again! John
Re: Writing a Sling content via output stream as opposed to
Posted by John Logan <Jo...@texture.com>.
No need to worry about this issue; I have something in place now.
Using piped streams was going to be a headache because the output stream needed to be in the main thread, meaning that the jcr:data property update run in a thread, necessitating the use of a service resolver. I didn't want to go there.
I instead created an extension of FilterOutputStream over a temporary FileOutputStream, overriding the close method to do the property update there.
It's inefficient, but it solves my problem.
John