Hi,
I’m implementing a Confluence Macro, using some of the objects available in the VTL context.
What I want to do is to access the underlying JSON content of an attachment.
So far I’m able to access the attachment with this code (a mix of VTL and Javascript):
#set($vtl_filename = 'my_file.json')
var filename = "$vtl_filename";
#set ($att = $attachmentManager.getAttachment($content, $vtl_filename))
#if (! $att)
console.log("no attachment found");
#else
console.log("attachement found");
#set($data = $attachmentManager.getAttachmentData($att))
## How can I get the String value of $data ???
#end
However I’m stuck with the getAttachmentData
function, which returns an InputStream
(or more precisely, a FileInputStream
). I want to get the content as a string (the JSON in the attachment), e.g. read what’s in the stream.
How can I do that using VTL? Is there a way to dump what’s in the stream into a String?
Also, How would I pass the result to the Javascript side of the Macro?
Thanks