New WebDAV Ruby On Rails Plugin Release
January 6th, 2007
I’ve finally had some time over the holidays to put together a new release of the RailsDAV plugin for WebDAV functionality in Rails.
It’s still really a 0.0.2 release as bugs are to be fixed and still havn’t nailed a structure for the plugin i’m happy with. But for now I have improved the structure and implemented some fixes courtesy of Albert Ramstedt. Thanks Albert.
As such the use of RailsDAV plugin has changed a bit and it won’t be backwards compatible so scan the code if you are using it.
The act_as_railsdav method is attached to ActionController and can be used by calling act_as_railsdav on a controller
class MyDavController < ActionController::Base
act_as_railsdav
The controller must then have a route of
map.connect 'mydav/*path_info', :controller => 'my_dav', :action => 'webdav'
It is then necessary to implement some or all of the following methods:
- mkcol_for_path(path)
- write_content_to_path(path, content),
- copy_to_path(resource, dest_path, depth)
- move_to_path(resource, dest_path, depth)
- get_resource_for_path(path)
get_resource_for_path needs to return a WebDAVResource object such as FileWebDavResource
To add webdav authentication to your controller just use
class MyDavController < ActionController::Base
act_as_railsdav
before_filter :my_auth
def my_auth()
basic_auth_required |username, password| do
session[:user] = User.your_authentication(username,password)
end
end
Additionally you can add a simple filesystem expose to a controller by:
class FileDavController < ActionController::Base
act_as_filewebdav :base_dir => 'public'
end
The new version of the plugin can be donwloaded using
svn co http://svn.liverail.net/svn/plugins/railsdav
It also requires the following gems
- unicode (gem install unicode)
- mimetypes (gem install mime-types)
I’m going to spend a lot more time on RailsDAV now so let me know what you want out of it!
January 7th, 2007 at 09:47 AM
Nice work Stuart! I still have a need for WebDAV in Rails, so I will be using your plugin in the near future. I’m sorry I wasn’t able to contribute (yet), I’ve been awfully busy. Also, I’m starting out using Flex with Rails as well.
January 8th, 2007 at 07:10 PM
This is looking good, thanks! All it needs for me is ability to set the base_dir dynamically. :)
January 8th, 2007 at 10:29 PM
yep thats in the TODOs ;-)
January 9th, 2007 at 02:00 PM
Thanks Stuart. I’ m really looking forward to the next RailsDAV release and it’s good to read, that you will work on improvements. Keep on your great work.
February 17th, 2007 at 10:32 AM
Thanks for it. I’m looking forward to the next release too.
February 24th, 2007 at 09:12 AM
Hi there. This looks really useful. I noticed that in your description of the new version, you don’t mention the ActiveRecord exposer which existed in versions past. Any plans to support that again? That’d really be awesome thing to have for many Rails apps, I’m sure.
Many thanks and please keep up the good work!
February 25th, 2007 at 10:59 PM
The active record version was always meant more of an example as how to use railsdav to expose things other than directories over webdav rather than anything really useful. I might be tempted to do some other clever active record things as examples if people are interested.
February 27th, 2007 at 07:51 PM
Definitely interested. Thanks!
April 16th, 2007 at 05:43 PM
has anyone tested this with the windows xp webdav clients (there are 2 – one that comes when you specify a port – the other one when you don´t). the only way i found out that it works is when you use the one that works with the port specified. And this one only seems to work when you use mongrel or something similar directly or with a proxy in front not in a fastcgi setup because apache doesn´t let the rails app answer the http options request (well that´s an apache problem but still its not so comfortable)
April 23rd, 2007 at 09:45 PM
Yes there has been a lot of testing on windows. I think the problem is with the apache setup but i have run a successfully before using a Lighttpd FCGI setup behind an apache proxy but i’ll try to test it out with a few different setups.
May 1st, 2007 at 09:54 AM
Oh, I just found this post! Thanks for mentioning me. I sortof abandoned the ServeWebdav gem, so its good that you found it useful. I have tested the ServeWebdav gem on macs and windows default/netdrive, and it worked pretty good. I never really got performance to an acceptable level for my own use (mapping AR).
July 18th, 2007 at 08:44 AM
Thank you!
July 25th, 2007 at 06:30 AM
Definitely interested. Thanks!
October 12th, 2007 at 09:43 AM
To be able to handle large files, getting the contents streamed to a yield-block would be nice. Do you already have a version of webdav_put() that does this? A test for respond_to?(:webdav_put_streamed) would probably be enough.
August 6th, 2008 at 08:17 AM
Great stuff so far. What about security? Is there a way to use https with filedav?
Cheers
August 6th, 2008 at 08:21 AM
Hi!
How do I upload a whole folder containing multiple files?
I cannot figure it out!
Thanks
September 24th, 2008 at 07:25 AM
本当にいいですね。