Coder Social home page Coder Social logo

webdavclient's Introduction

WebdavClient

A very simple C++ interface for the webdav neon lib

Description

WebdavClient is a C++ class, that makes it very easy to transmit data between a local machine and a webdav server. All the complex neon calls are hidden behind some methods of the WebdavClient class.

Build

  • Include WebdavClient.h
  • compile with -lneon
  • example: g++ main.cc WebdavClient.cc -I . -lneon

Example

All methods of WebdavClient class used in a simple example.

#include <WebdavClient.h>
#include <iostream>

int main(){
  
  const std::string host("my_webdavserver.com");
  const std::string user("my_user");
  const std::string pass("my_password");
  const std::string uri("/my_location/");
  const unsigned port = 80;

  WebdavClient webdavClient(host, port, user, pass);

  // Upload a file to webdav server
  if(webdavClient.put(uri + "my_file_put", "my_file_put")){
    std::cout << "Upload succesfull!" << std::endl;
  }
  else {
    std::cout << "Upload error! " << webdavClient.getLastError() << std::endl;
  }

  // Download a file from webdav server
  if(webdavClient.get(uri + "my_file_put", "my_file_get")){
    std::cout << "Download successfull!" << std::endl;
  }
  else {
    std::cout << "Download error! " << webdavClient.getLastError() << std::endl;
  }

  // Check if a file on webdav server exists
  if(webdavClient.exist(uri + "my_file_put")){
    std::cout << "File exists! "  << std::endl;
  }
  else {
    std::cout << "File does not exist! " << webdavClient.getLastError() << std::endl;
  }

  // Create directory on webdav server
  if(webdavClient.mkdir(uri + "new_dir")){
    std::cout << "Create folder successfull!" << std::endl;
  }
  else {
    std::cout << "Create folder error! " << webdavClient.getLastError() << std::endl;
  }

  // Remove a file on webdav server
  if(webdavClient.rm(uri + "my_file_put")){
    std::cout << "Remove file successfull!" << std::endl;
  }
  else {
    std::cout << "Remove file error! " << webdavClient.getLastError() << std::endl;
  }

  // Remove a directory on webdav server
  if(webdavClient.rm(uri + "new_dir/")){
    std::cout << "Remove directory successfull!" << std::endl;
  }
  else {
    std::cout << "Remove directory error! " << webdavClient.getLastError() << std::endl;
  }

  return 0;
}

Dependencies

  • neon
  • c++99

Copyrigth

License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Author

Written by Erik Zenker ([email protected])

webdavclient's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.