[xwiki-devs] OfficeImporter wysiwyg plugin issues (File Import Tab)
Hi Devs, As reported @ http://jira.xwiki.org/jira/browse/XWIKI-3288 and http://jira.xwiki.org/jira/browse/XAOFFICE-10, OfficeImporter wysiwyg plugin has issues with importing some documents on some platforms. When importing documents from the wysiwyg plugin, the approach we follow is to upload the file that need to be imported into the current page and then import the corresponding attachment. But this scheme has two problems: 1) If the file being uploaded contains special characters, the attachment name will be different from the file name. And this will cause the officeimporter to fail because after uploading the file we will be making a second request to import the attachment with the original file name (but now there is no such attachment). 2) The fileName returned by GWT FileUpload widget is different from Firefox to IE. While Firefox returns the file name, IE returns the whole file path. This causes the officeimporter wysiwyg plugin to fail completely under IE (File Import Tab only). The solution I can see is the following, 1) Upload the file as an attachment just as before. 2) Make a second rpc call. This RPC call will import the latest attachment to the current page by the current user. This way we don't need to worry about crappy file names and browser specific stuff. I know it's a bit ugly but it will work. WDYT? Thanks.
Hi, 1) Upload the file as an attachment just as before.
2) Make a second rpc call. This RPC call will import the latest attachment to the current page by the current user. This way we don't need to worry about crappy file names and browser specific stuff.
I Implemented this approach and it works fine and fixes both the issues http://jira.xwiki.org/jira/browse/XWIKI-3288 and http://jira.xwiki.org/jira/browse/XAOFFICE-10 Still I'm wondering if this is the correct approach or not. I won't commit the code for the moment, in the mean time if you have any comments please let me know. Thanks. - Asiri
Asiri Rathnayake wrote:
Hi,
1) Upload the file as an attachment just as before.
2) Make a second rpc call. This RPC call will import the latest attachment to the current page by the current user. This way we don't need to worry about crappy file names and browser specific stuff.
This solution is acceptable in most of the cases (provided you look for both new and updated attachments), but not bullet proof. Ideally, the upload action should tell us the name of the added/updated attachment. A hackish solution would be to use the xredirect hidden input in the upload form and make the upload action add the name of the attachment in the query string. This way you could force the upload action to redirect to an URL like /Space/Page?xpage=plainAttachmentName&attchmentName=foo. I don't know the details though so it might now work. Marius
I Implemented this approach and it works fine and fixes both the issues http://jira.xwiki.org/jira/browse/XWIKI-3288 and http://jira.xwiki.org/jira/browse/XAOFFICE-10
Still I'm wondering if this is the correct approach or not. I won't commit the code for the moment, in the mean time if you have any comments please let me know.
Thanks.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Asiri Rathnayake wrote:
Hi,
1) Upload the file as an attachment just as before.
2) Make a second rpc call. This RPC call will import the latest attachment to the current page by the current user. This way we don't need to worry about crappy file names and browser specific stuff.
I Implemented this approach and it works fine and fixes both the issues http://jira.xwiki.org/jira/browse/XWIKI-3288 and http://jira.xwiki.org/jira/browse/XAOFFICE-10
Still I'm wondering if this is the correct approach or not. I won't commit the code for the moment, in the mean time if you have any comments please let me know.
This solution, while working in most of the cases, is not interleaving-free. Between the moment of the upload and the moment of the RPC call (when you get last attachment), another attachment might have been uploaded and so you get a wrong and very strange result for the user. Even if it works in most of the cases, I think we should look for another solution that would really give back the name of the attachment, since we might need it in many other places. I'm not at all knowledgeable of the REST API, but if it were a method there to attach a file and send back attached file name in JSON (or something), it would be so great. Happy coding, Anca
Thanks.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Mar 25, 2009, at 11:15 AM, Anca Paula Luca wrote:
I'm not at all knowledgeable of the REST API, but if it were a method there to attach a file and send back attached file name in JSON (or something), it would be so great.
You can do this, it's already supported by the REST API. For example: curl -u Admin:admin -X PUT -H "Content-type: application/pdf" --data- binary @test.pdf http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome/attac... Will create an attachment on the Main.WebHome page and will return an XML containing all the information about the (newly created or updated) attachment. Something like: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <attachment xmlns="http://www.xwiki.org"> <link rel="http://www.xwiki.org/rel/page" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome "/> <link rel="http://www.xwiki.org/rel/attachmentData" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome/attac... "/> <id>xwiki:[email protected]</id> <name>test.pdf</name> <size>32990</size> <version>1.3</version> <pageId>xwiki:Main.WebHome</pageId> <pageVersion>6.1</pageVersion> <mimeType>application/pdf</mimeType> <author>XWiki.Admin</author> <date>2009-03-25+01:00</date> <xwikiRelativeUrl>/xwiki/bin/download/Main/WebHome/test.pdf</ xwikiRelativeUrl> <xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/download/Main/WebHome/test.pdf </xwikiAbsoluteUrl> </attachment> If you want this information in JSON, just add an "Accept: application/ json" to the request and you are done: curl -u Admin:admin -X PUT -H "Content-type: application/pdf" -H "Accept: application/json" --data-binary @test.pdf http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome/attac... { "mimeType":"application/pdf", "pageVersion":"8.1", "xwikiRelativeUrl":"/xwiki/bin/download/Main/WebHome/test.pdf", "xwikiAbsoluteUrl":"http://localhost:8080/xwiki/bin/download/Main/WebHome/test.pdf ", "size":32990, "date":"java.util.GregorianCalendar[time=1237978840000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id=\"Europe/Paris\",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Paris,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2009,MONTH=2,WEEK_OF_YEAR=13,WEEK_OF_MONTH=4,DAY_OF_MONTH=25,DAY_OF_YEAR=84,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=0,HOUR_OF_DAY=12,MINUTE=0,SECOND=40,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=0]", "name":"test.pdf", "id":"xwiki:[email protected]", "author":"XWiki.Admin", "version":"1.4", "pageId":"xwiki:Main.WebHome" } Hope this helps. Cheers, Fabio
participants (4)
-
Anca Paula Luca -
Asiri Rathnayake -
Fabio Mancinelli -
Marius Dumitru Florea