Davix is a lightweight toolkit for remote file interactions with HTTP based protocols.
Davix aims to supports all the needed features for an efficient file access and file management in grid and clouds : SSL Session reuse, X509 client auth, VOMS credential, S3 auth, Vector operations (Partial reads, multi-range, single range), Partial PUT / PATCH, Fail-over, Multi-streams ( Metalinks), Redirection support for all operations, Redirections caching, Webdav parsing, Right Management (ACL), Meta-data functions ( mkdir, rmdir, unlink, etc.. ), Chunked transfert, etc....
Davix supports the protocols
The Davix philosophy can be summarized as
File API : Davix::DavFile
Posix-like API : Davix::DavPosix
Entry point API : davix.hpp
In short : No
Libcurl defines itself as a "client side URL transfer".
it provides "protocol level" API, you compose your http queries mannually.
Create a directory :
{.cpp}
DavixError* tmp_err=NULL;
DavFile f(context, url);
// creat directory
p.makeCollection(NULL, &tmp_err);
Get a full file content:
{.cpp} DavixError* tmp_err=NULL; DavFile f(context, "http://mysite.org/file"); int fd = open("/tmp/local_file", O_WRONLY | O_CREAT); // get full file if( p.getToFd(NULL,fd, &tmp_err) < 0) std::cerr << "Error: " << tmp_err->getErrMsg() << std::endl;
Execute a partial GET :
{.cpp} char buffer[255] = {0} DavixError* tmp_err=NULL; DavFile f(context, "http://mysite.org/file"); // get 100 bytes from http://mysite.org/file after an offset of 200 bytes if( p.readPartial(NULL, buffer, 100, 200 &tmp_err) <0 ) std::cerr << "Error: " << tmp_err->getErrMsg() << std::endl; else std::cout << "Content: " << buffer << std::endl;
Execute a Vector Operation :
{.cpp} char buffer[255] = {0} DavixError* tmp_err=NULL; DavFile f(context, "http://mysite.org/file"); DavIOVecInput in[3]; DavIOVecOutput ou[3]; // get 100 bytes from http://mysite.org/file after an offset of 200 bytes if( p.readPartial(NULL, buffer, 100, 200 &tmp_err) <0 ) std::cerr << "Error: " << tmp_err->getErrMsg() << std::endl; else std::cout << "Content: " << buffer << std::endl;
Stat query :
{.cpp} Davix::DavPosix p; // state quer p.stat("https://mywebdav-server.org/mydir/", &stat, &tmp_err);
random I/O :
{.cpp} // // read ops fd= p.open(NULL, "https://mywebdav-server.org/myfile.jpg", O_RDONLY, &tmp_err); p.read(fd, buffer, size, &tmp_err); p.pread(fd, buffer, size2, offset, &tmp_err); p.close(fd); //
{.cpp} Davix::HttpRequest req("https://restapi-server.org/rest") req.addHeaderField(...) req.setRequestMethod("PUT") // .. configure .... // // // execute your request req.executeRequest(...);
davix has a set of command line tools for testing purpose and demonstration
-> davix-ls: file listing -> davix-get: download operations -> davix-put: upload operations -> davix: low level query composition
please contact us on davix-devel@cern.ch ( CERN e-group & mailing list ) or on adrien.devresse@cern.ch
Any contribution is welcome
https://svnweb.cern.ch/trac/lcgutil/wiki/davix