Hallo,
I have a problem when I create a report at ARIS 9.8.
I was upload file to Document Storage link. And I tried to create script but it's not work. Because script error.
var attrDoc = dataofModels5[z].Attribute(Constants.AT_ADS_LINK_1,nLocale);
if (attrDoc != "Attr[4015,[Binary data], locale=1033]@0") {
p_output.BeginSection(false, Constants.SECTION_DEFAULT)
sectionPageSetup2( xx, p_output )
var bytearray = attrDoc.getExternalDocument().getDocument();
var docVal = Context.getOutputObject(file,bytearray);
p_output.InsertDocument(docVal, false, false);
p_output.EndSection()
Does anyone know how to get output file in document storage link??
Please help me. and thank you for your attention.
Kay Fischbach on
Unfortunately this seems to be a complicated topic.You can't use getExternalDocument() because the ADS is protected by authentication mechanisms. getExternalDocument is useful when you try to retrieve a document from a normal file system, like a shared network drive.
To retrieve files from the ADS you have to load the ADS report component and use that to get your file. Unfortunately the ADS report component only provides the file content as a Java InputStream, which makes things quite complicated.
Here is a very crude, but working approach. Feel free to improve it as much as possible.
Note here: I seriously hope that java.io.File.createTempFile(...) and tempFile.deleteOnExit() work as intended. It would be super bad if this would somehow leave remnants on the ARIS server, clogging the system.
Edit: after getting the byte array with java.nio.file.Files.readAllBytes(...) you can also call tempFile.delete() to delete the temp file. This ensures there won't be temp files piling up on your server.