Max_iKiC Posted December 14, 2012 Share Posted December 14, 2012 Hi everyone, I would like to present you the net_dav library which is a Ruby library that provides access to online file storage. I represent the online storage iKeepinCloud. There is an unlimited storage and is working with the protocol WebDAV. I would like to know your opinion on working the library on this online storage. Nothing more. You can find the full tutorial here : http://www.ikeepincl...en/ruby_library And the scripts here : http://www.ikeepincl.../en/ruby_script 1. Introduction The net_dav library allows you to upload (PUT), download (GET) and delete (DELETE) files stored on iKeepinCloud with the WebDAV protocol. 2. Latest version Latest version v0.5.0-24 (released 2010/03/12) Download available here : https://github.com/devrandom/net_dav This version is supported by Unix, Windows and Mac and operates under Apache 2. 3. Installation Installation of the gem: gem install net_dav You can also install curb to speed up the transfer of large files: gem install curb If you have trouble installing Nokogiri on Mac OS X: http://nokogiri.org/...g_nokogiri.html Ubuntu users will need openssl. 4. Documentation RDoc: rdoc.info/projects/devrandom/net_dav Wiki: wiki.github.com/devrandom/net_dav 5. Example We will create the testdav.rb file, a Ruby script executed through the command line: ruby testdav.rb. We will now import the net/dav library that will allow us to make the necessary calls to interact with the WebDAV server. require 'rubygems' require 'net/dav' Now we will define the URL to connect to iKeepinCloud (for example, for the user "pcollins") then the authentication information needed to access a protected resource. url = "https://pcollins.ike...eepincloud.com" user = "pcollins" pasw = "mypass" Now we will create a new DAV client for the previous URL (the HTTPS protocol will be used because it is defined in the url). Note that it is possible to activate the curl module to speed up the transfer of large files. dav = Net::DAV.new(url, :curl => false) dav.verify_server = false # Ignore server verification We will then call the credentials() function to define the authentication information associated with this url, which is needed when the client requests access to a protected resource (https). dav.credentials(user, pasw) We can now start by creating the root / of a new directory called "test": dav.mkdir("/essai") Let's continue with uploading a file to the "/test" directory in iKeepinCloud. We will open the local file to upload using the open() command, then perform the upload with the net/dav put command: locpath = "C:\\testdav\\test_file.txt" File.open(locpath, "r") do |stream| dav.put("/test/test.txt", stream, File.size(locpath)) end We can now download this "test/test.txt" file and move it to the local location: "C:\testdav\test\test_file.txt". Once the content is downloaded, we will save it in the selected file. content = dav.get("/test/test.txt") locpath = "C:\\testdav\\test\\test_file.txt" File.open(locpath, "w") do |stream| stream To delete the file previously created, call the delete() command: dav.delete("/test/test.txt") You can also delete a directory with the delete() command: dav.delete("/test") Quote Link to comment https://forums.phpfreaks.com/topic/271997-php-dav-library-sabredav-for-setting-up-a-webdav-client/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.