From zorro.lp.x@gmail.com Thu Feb 28 03:19:46 2008 From: Ngo Thi Hong Nga To: xwiki-users@xwiki.org Subject: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 09:19:42 +0700 Message-ID: <81827c930802271819x57cfeb22kbd37029ee8760d94@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4796287569128926241==" --===============4796287569128926241== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, I want to create a page allowed to upload more files together using FileUploadPlugin. I created 2 documents but the FileUploadPlugin seems not work, the data return is null and the document MySpace.Upload is attached with a file 0KB. Anyone can explain me why this happens ? And how to fix ? 1. MySpace.doc:
2. MySpace.Upload <% import com.xpn.xwiki.plugin.fileupload.FileUploadPlugin; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.doc.XWikiAttachment; print "Start upload... "; def docu=doc.getDocument(); FileUploadPlugin fileupload = (FileUploadPlugin) context.getContext().get("fileuploadplugin"); byte[] data = fileupload.getFileItemData("filepath", context.getContext()); def filename = "myfile"; def attachment = docu.getAttachment(filename); print data; if (!attachment) { attachment = new XWikiAttachment(docu, filename); docu.getAttachmentList().add(attachment); } attachment.setContent(data); docu.saveAttachmentContent(attachment, context.getContext()); doc.save() println "done" %> --===============4796287569128926241==-- From ludovic@xwiki.org Thu Feb 28 13:15:07 2008 From: Ludovic Dubost To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 13:15:04 +0100 Message-ID: <47C6A5C8.1040609@xwiki.org> In-Reply-To: <81827c930802271819x57cfeb22kbd37029ee8760d94@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1197453513405751003==" --===============1197453513405751003== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Which version of XWiki are you using ? There is some issue that makes some code empty the file upload list. Can you try by posting to a page with that in the URL ?xpage=plain Also you should be able to do this without going to the internal API. There is addAttachment in Document Here is a test code that shows the file upload plugin in action to show that you get data: 1 File Upload Snipplet <% if (request.get("submitter")!=null) { def fupl= xwiki.get("fileupload"); println fupl; def myfiles = fupl.getFileItems(); println "{pre}" println myfiles; println "{/pre}" println fupl.getFileName("file") } else { %>
Submitter:
File:
<% } %> Ngo Thi Hong Nga wrote: > Hi, I want to create a page allowed to upload more files together > using FileUploadPlugin. I created 2 documents but the FileUploadPlugin > seems not work, the data return is null and the document > MySpace.Upload is attached with a file 0KB. Anyone can explain me why > this happens ? And how to fix ? > > 1. MySpace.doc: >
enctype="multipart/form-data" method="post"> > > >
> 2. MySpace.Upload > <% > import com.xpn.xwiki.plugin.fileupload.FileUploadPlugin; > import com.xpn.xwiki.doc.XWikiDocument; > import com.xpn.xwiki.doc.XWikiAttachment; > > print "Start upload... "; > def docu=doc.getDocument(); > FileUploadPlugin fileupload = (FileUploadPlugin) > context.getContext().get("fileuploadplugin"); > byte[] data = fileupload.getFileItemData("filepath", context.getContext()); > def filename = "myfile"; > def attachment = docu.getAttachment(filename); > > print data; > if (!attachment) { > attachment = new XWikiAttachment(docu, filename); > docu.getAttachmentList().add(attachment); > } > attachment.setContent(data); > docu.saveAttachmentContent(attachment, context.getContext()); > doc.save() > > println "done" > %> > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > > -- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost --===============1197453513405751003==-- From zorro.lp.x@gmail.com Thu Feb 28 13:40:16 2008 From: Ngo Thi Hong Nga To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 19:40:08 +0700 Message-ID: <81827c930802280440w362e29ebq1d20d059b5bed565@mail.gmail.com> In-Reply-To: <47C6A5C8.1040609@xwiki.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5813978543087688899==" --===============5813978543087688899== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit I use XE 1.1.2. I create a document and paste your test code in. After browse a file, click Submit, the following line is displayed: com.xpn.xwiki.plugin.fileupload.FileUploadPluginApi(a)1015495 null null --===============5813978543087688899== Content-Type: text/html Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="attachment.html" MIME-Version: 1.0 SSB1c2UgWEUgMS4xLjIuPGJyPkkgY3JlYXRlIGEgZG9jdW1lbnQgYW5kIHBhc3RlIHlvdXIgdGVz dCBjb2RlIGluLiBBZnRlciBicm93c2UgYSBmaWxlLCBjbGljayBTdWJtaXQsIHRoZSBmb2xsb3dp bmcgbGluZSBpcyBkaXNwbGF5ZWQ6PGJyPjxicj48c3BhbiBzdHlsZT0iYmFja2dyb3VuZC1jb2xv cjogcmdiKDI1NSwgMjU1LCA1MSk7Ij5jb20ueHBuLnh3aWtpLnBsdWdpbi5maWxldXBsb2FkLkZp bGVVcGxvYWRQbHVnaW5BcGlAMTAxNTQ5NSBudWxsIG51bGw8L3NwYW4+Cg== --===============5813978543087688899==-- From ludovic@xwiki.org Thu Feb 28 14:25:59 2008 From: Ludovic Dubost To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 14:25:56 +0100 Message-ID: <47C6B664.70408@xwiki.org> In-Reply-To: <81827c930802280440w362e29ebq1d20d059b5bed565@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1178611603408502326==" --===============1178611603408502326== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Can you try by changing
to Ludovic Ngo Thi Hong Nga wrote: > I use XE 1.1.2. > I create a document and paste your test code in. After browse a file, > click Submit, the following line is displayed: > > com.xpn.xwiki.plugin.fileupload.FileUploadPluginApi(a)1015495 null null > ------------------------------------------------------------------------ > > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > -- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost --===============1178611603408502326==-- From zorro.lp.x@gmail.com Thu Feb 28 14:33:00 2008 From: Ngo Thi Hong Nga To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 20:32:53 +0700 Message-ID: <81827c930802280532l7e987100s91d64384572a8f10@mail.gmail.com> In-Reply-To: <47C6B664.70408@xwiki.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3604630074832605435==" --===============3604630074832605435== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Still the same result: null :( Have you tested your code snippet before posted here? Does it run properly? If yes, which version of XE you are using ? Can you test my code in your XE and tell me the result ? --===============3604630074832605435== Content-Type: text/html Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="attachment.html" MIME-Version: 1.0 U3RpbGwgdGhlIHNhbWUgcmVzdWx0OiBudWxsIDooPGJyPkhhdmUgeW91IHRlc3RlZCB5b3VyIGNv ZGUgc25pcHBldCBiZWZvcmUgcG9zdGVkIGhlcmU/IERvZXMgaXQgcnVuIHByb3Blcmx5PyBJZiB5 ZXMsIHdoaWNoIHZlcnNpb24gb2YgWEUgeW91IGFyZSB1c2luZyA/IENhbiB5b3UgdGVzdCBteSBj b2RlIGluIHlvdXIgWEUgYW5kIHRlbGwgbWUgdGhlIHJlc3VsdCA/PGJyPgo= --===============3604630074832605435==-- From ludovic@xwiki.org Thu Feb 28 16:00:05 2008 From: Ludovic Dubost To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 16:00:02 +0100 Message-ID: <47C6CC72.7070900@xwiki.org> In-Reply-To: <81827c930802280532l7e987100s91d64384572a8f10@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3706857675038251698==" --===============3706857675038251698== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit It runs fine on 1.2 and 1.3 Try an upgrade Ludovic Ngo Thi Hong Nga wrote: > Still the same result: null :( > Have you tested your code snippet before posted here? Does it run > properly? If yes, which version of XE you are using ? Can you test my > code in your XE and tell me the result ? > ------------------------------------------------------------------------ > > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > -- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost --===============3706857675038251698==--