Jump to content

Recommended Posts

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")

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.