From version < 4.15 >
edited by Alexandru Colesnicov
on 2019/10/02 14:04
To version < 4.23 >
edited by Alexandru Colesnicov
on 2019/10/02 14:47
< >
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -2,26 +2,35 @@
2 2   import com.xpn.xwiki.*;
3 3   import com.xpn.xwiki.api.*;
4 4   import com.xpn.xwiki.doc.*;
5 - import org.apache.commons.io.FileUtils;
6 6   import java.io.File;
7 - import java.net.URL;
8 8  
9 - // y=XWikiAttachment(xwiki.getDocument(doc.parent), "aFileVerified").getAttachment_content().storageFile;
10 - //y=xwiki.getDocument(doc.parent).XWikiAttachment.getAttachment_content().storageFile;
7 + println ("* Solution in 4 steps\n")
11 11  
12 12   att = doc.getAttachment("TestingData.xls")
13 - println (att.getClass().getSimpleName() + " (" + att.getClass().getName() + ")")
10 + println ("att = doc.getAttachment(\"TestingData.xls\")")
11 + println (" att: variable got its value")
12 + println (" att: Class is " + att.getClass().getSimpleName() + " (" + att.getClass().getName() + ")")
14 14  
15 15   xwa = att.getAttachment()
16 - println (xwa.getClass().getSimpleName() + " (" + xwa.getClass().getName() + ")")
15 + println ("xwa = att.getAttachment()")
16 + println (" xwa: variable got its value")
17 + println (" xwa: Class is " + xwa.getClass().getSimpleName() + " (" + xwa.getClass().getName() + ")")
17 17  
18 18   sfi = xwa.getAttachment_content().storageFile
19 - println (sfi.getClass().getSimpleName() + " (" + sfi.getClass().getName() + ")")
20 + println ("sfi = xwa.getAttachment_content().storageFile")
21 + println (" sfi: variable got its value")
22 + println (" sfi: Class is " + sfi.getClass().getSimpleName() + " (" + sfi.getClass().getName() + ")")
20 20  
21 - //aco = att.getAttachment_content()
24 + apa = sfi.getAbsolutePath()
25 + println ("apa = sfi.getAbsolutePath()")
26 + println (" apa: variable got its value = " + apa)
27 + println (" apa: Class is " + apa.getClass().getSimpleName() + " (" + apa.getClass().getName() + ")")
22 22  
23 -// for (XWikiAttachment attach in doc.getAttachmentList()) {
24 -// println "** " + attach.filename;
25 -// }
26 - //println y;
29 + println ("* Solution in 1 step\n")
30 +
31 + apa2 = doc.getAttachment("TestingData.xls").getAttachment().getAttachment_content().storageFile.getAbsolutePath()
32 + println ("apa2 = doc.getAttachment(\"TestingData.xls\").getAttachment().getAttachment_content().storageFile.getAbsolutePath()")
33 + println (" apa2: variable got its value = " + apa2)
34 + println (" apa2: Class is " + apa2.getClass().getSimpleName() + " (" + apa2.getClass().getName() + ")")
35 +
27 27  {{/groovy}}