I've made my own upload form because I need to intercept an upload and
save it different places at once, potentially resize it in the process.
Essentially I use the fileupload plugin. Grep the data and use the
$doc.addAttachment(filename, byte[]) function.
I do however run into trouble. First It all goes fine, I can upload
fine and the attachment is present in both document. But after some
time it simply disappears. Ether it is not saved correctly (only in
cache?) or something else is terribly wrong.
Do I need to call some kind of save function?
In the admin dashboard I can see that I made some new documents and
uploaded files to them. But on the Document itself there doesn't seem to
be history of when the file was uploaded, nor a option to role back.
So any help or ideas would be appreciated.
Here is the attachment saving part of the code (don't mind the file
naming code it works!):
#set( $up = $xwiki.getPlugin("fileupload"))
#set( $wallCardData = $up.getFileItemData(
$wallCardName.toLowerCase() ) )
#if($listtool.size($wallCardData) > 0)
#set( $ext =
"#fileextension($up.getFileName($wallCardName.toLowerCase()))")
## Store the original file in XWiki.WallCards as
<Space>-<Page>-<Filename>
#set( $oriFileName =
"${doc.getSpace()}-${doc.getName()}-$wallCardName$ext" )
#set( $oriatt = $xwiki.getDocument( $oriFileDocument
).addAttachment($oriFileName,
$up.getFileItemData($wallCardName.toLowerCase()) ) )
#set( $att = $doc.addAttachment( "$wallCardName$ext",
$up.getFileItemData($wallCardName.toLowerCase())) )
#end
-Rune
Show replies by date