This is a bit of a late reply, but I've implemented this and am wondering what you would recommend doing about security with this approach.
On Thu, Jul 15, 2010 at 5:10 PM, Sergiu Dumitriu <[email protected]> wrote: > > On 07/15/2010 04:55 PM, Carlos Correa wrote: > > One of the users of the xwiki server (*nix) that I'm helping with has > > an interesting feature request. He wants a wiki page with a listing of > > Microsoft Office files that are in a unix directory. He wants to be > > able to click on one of the file names and have it download. > > > > I don't know enough about xwiki to know how to cause a download to > > occur on the user's side. The only solution I can think of is > > attaching the files to the page and scripting regular updating (which > > is very clunky). Is there a more elegant way to cause downloads to > > occur on the user's end without adding the file as an attachment? > > Well, XWiki is a java application, so the easiest thing to do is to > write a Java component that does this. Assuming you have a recent > version of XWiki, you should: > - write a scriptable service which can list the files on the filesystem; > should be a ScriptService component if you're targeting XWiki 2.3 or > later, or a VelocityContextInitializer for earlier; see > http://code.xwiki.org/xwiki/bin/view/Modules/ComponentModule for general > documentation about components > - write a servlet or a struts action which can be used to retrieve the > contents of the file; make sure you're not creating a security hole, > check the absolute path requested by the user; a good example would be > http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/TempResourceAction.java > - register the above servlet/struts action in web.xml, respectively > struts-config.xml > > -- > Sergiu Dumitriu > http://purl.org/net/sergiu/ > _______________________________________________ > users mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
