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.
#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?