On 03/27/2010 02:27 PM, Gerritjan Koekkoek wrote:
Hi,
Is there a code snippet (groovy or Velocity) to attach a file (jpg and/or gif) to a
document?
The files are stored in a directory on my Mac os X computer
1. You can't attach through scripting a file that is not on the server.
2. Velocity does not have the API to access files on the server.
3. Groovy is like Java, so writing the example in Java first should end
up in the Groovy snippet.
4. The code for converting binary data to an attachment and adding it to
a document is in xwiki-core/com.xpn.xwiki.web.UploadAction#uploadAttachment
So, after you read the contents of the file into a byte[], just do
what's done in that method.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/