net_dav icon indicating copy to clipboard operation
net_dav copied to clipboard

method for locking, unlocking resources.

Open ghost opened this issue 10 years ago • 5 comments

Is there any method for locking, unlocking resources. I couldn't find it in dav.rb file

ghost avatar Feb 12 '15 10:02 ghost

Locking and unlocking is supported. In dav.rb "lock" is one of the supported verbs.

thomasfl avatar Feb 12 '15 12:02 thomasfl

fine, thanks! But when installed using gem 'net_dav', '~> 0.5.0' . It doesn't have those methods in dav.rb file.

ghost avatar Feb 12 '15 12:02 ghost

You have the latest release of net_dav.

require 'rubygems'
require 'net/dav'
require 'uri'

dav = Net::DAV.new('http://www.example.com/')
dav.credentials(ENV['DAVUSER'],ENV['DAVPASS'])

uri = URI.parse('http://www.example.com/unlocked_file.txt')
dav.lock(uri.path, "<d:lockscope><d:exclusive/></d:lockscope><d:locktype><d:write/></d:locktype><d:owner>Owner</d:owner>")
dav.unlock(uri.path, "opaquelocktoken:<insert token here>")

I recommend you add pry to your code to start a irb like shell, and experiment a little

require 'pry'
binding.pry

I don't work with WebDAV servers anymore, so I would have to install a server to be able to create some sample code.

thomasfl avatar Feb 13 '15 09:02 thomasfl

thanks @thomasfl , When I looked for lock, unlock method in dav.rb file in my local machine. I couldn't find. But it is available in github. so i used it.

ghost avatar Feb 13 '15 10:02 ghost

Cool! Good luck.

thomasfl avatar Feb 13 '15 10:02 thomasfl