{"id":13460661,"url":"https://jothepro.github.io/libCloudSync/","last_synced_at":"2025-03-24T19:32:25.643Z","repository":{"id":117384696,"uuid":"351524744","full_name":"jothepro/libCloudSync","owner":"jothepro","description":"A simple to use C++ interface to interact with cloud storage providers.","archived":false,"fork":false,"pushed_at":"2021-12-20T13:56:59.000Z","size":734,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-01T10:21:33.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jothepro.github.io/libCloudSync/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jothepro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-03-25T17:43:03.000Z","updated_at":"2024-05-27T00:37:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7548896-d480-4089-8734-643aa70dc44a","html_url":"https://github.com/jothepro/libCloudSync","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"jothepro/cpp-library-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jothepro%2FlibCloudSync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jothepro%2FlibCloudSync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jothepro%2FlibCloudSync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jothepro%2FlibCloudSync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jothepro","download_url":"https://codeload.github.com/jothepro/libCloudSync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222004233,"owners_count":16914875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T10:00:46.564Z","updated_at":"2024-10-29T06:30:43.276Z","avatar_url":"https://github.com/jothepro.png","language":"C++","funding_links":[],"categories":["Examples"],"sub_categories":[],"readme":"# libCloudSync\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/jothepro/libcloudsync)](https://github.com/jothepro/libcloudsync/releases/latest)\n[![GitHub](https://img.shields.io/github/license/jothepro/libcloudsync)](https://github.com/jothepro/libcloudsync/blob/main/LICENSE)\n\nA simple-to-use C++ interface to interact with cloud storage providers.\n\n## Features\n\n- ☁️ Supported Cloud Providers:\n  - Nextcloud\n  - Dropbox\n  - Onedrive\n  - GDrive\n  - WebDav\n\n## Installation\n\nTo use this library in you project, you can install it in the following ways:\n\n### Conan\n```sh\n# Add conan remote:\nconan remote add gitlab-cloudsync https://gitlab.com/api/v4/projects/15425736/packages/conan\n```\n\n```ini\n[requires]\nlibcloudsync/0.1.0@jothepro/release\n```\n\nIf you don't want to build \u0026 run tests when building from source, set the [CONAN_RUN_TESTS](https://docs.conan.io/en/latest/reference/env_vars.html#conan-run-tests) variable:\n```sh\nconan install -if build --build missing . -e CONAN_RUN_TESTS=0\n```\n\n## Quick start\n\n```cpp\n// if this is the users first login, provide the authorization code to get a fresh access_token \u0026 refresh_token\nauto credentials = OAuth2Credentials::from_authorization_code(client_id, authorization_code, redirect_uri, code_verifier);\n// if you already have an access token that is still valid, create a session that will automatically refresh when the token gets outdated\nauto credentials = OAuth2Credentials::from_access_token(access_token, refresh_token, valid_until);\n// if the access_token that you stored is already expired, just initialize with the refresh token, it will get a new access_token for you\nauto credentials = OAuth2Credentials::from_refresh_token(refresh_token);\n// listen on any token update. This will be called with a fresh access_token \u0026 refresh_token if you just provided an authorization_code.\n// Otherwise just the access_token will change and the refresh token will be unchanged\ncredentials-\u003eon_token_update([this](const std::string\u0026 access_token, std::chrono::time_point expires, const std::string\u0026 refresh_token){\n    // store the new access_token/refresh_token \n})\nauto cloud = CloudFactory().create_dropbox(credentials);\ntry {\n    auto root_directory = cloud-\u003eroot();\n    root_directory-\u003eget_file(\"test.txt\");\n} catch(const CloudException \u0026e) {\n    std::cerr \u003c\u003c \"Sth went wrong: \" \u003c\u003c e.what() \u003c\u003c std::endl;\n}\n```\n\n```cpp\nauto credentials = BasicCredentials::from_username_password(\"john\", \"password123\");\nauto cloud = CloudFactory().create_nextcloud(\"https://my.nextcloud-cloud.com\", credentials);\ntry {\n    auto file = cloud-\u003eroot()-\u003ecreate_file(\"test.txt\");\n} catch(const CloudException \u0026e) {\n    std::cerr \u003c\u003c \"Sth went wrong: \" \u003c\u003c e.what() \u003c\u003c std::endl;\n}\n```\n\n## Development\n\n### Build Requirements\n\n- Conan \u003e= 1.40\n- CMake \u003e= 3.15\n- Doxygen \u003e= 1.9.1 (optional)\n\n### Build\n\n- **Commandline**:\n  ```sh\n  # install dependencies with Conan\n  conan install -if build --build missing .\n  # configure, build \u0026 test with Conan\n  conan build -bf build .\n  # or configure \u0026 build directly with CMake\n  cmake -S . -B build \u0026\u0026 cmake --build build\n  # and execute the tests with ctest\n  ctest --test-dir build/test\n  ```\n- **Clion**: Install the [Conan Plugin](https://plugins.jetbrains.com/plugin/11956-conan) before configuring \u0026 building the project as usual.\n\n### Test\n\nThis library uses [Catch2](https://github.com/catchorg/Catch2) for testing. The Unit-tests are defined in `test`.\n\n- **Commandline**: To run just the unit-tests, you can run `conan build -bf build --test .`.\n- **CLion**: Execute the `CloudSyncTest` target\n\n### Integration Test\n\nTo ensure that the library behaves consistently with all cloud providers, the integration test runs a series of \nfilesystem operations and checks for the correct results while being connected to the real cloud provider.\n\nTo execute the tests you need to provide valid credentials to an account for each of the supported providers.\n\n### Example CLI\n\nA small CLI example implementation is provided, to show the capabilities of the library.\n\n```sh\n# build the example \ncmake --build build --target CloudSyncExample\n# execute the program\ncd build/example\n./CloudSyncExample --help\n# usage example: connect to a dropbox app folder\n./CloudSyncExample --dropbox --token \u003cyour-access-token\u003e\n```\n\n#### Using the example CLI\n\n##### GDrive\n\n1. Get an access token from the [OAuth 2.0 Playground](https://developers.google.com/oauthplayground) with the following\n   permissions:\n  - `https://www.googleapis.com/auth/userinfo.profile` for loading the user profile.\n  - `https://www.googleapis.com/auth/drive` if you want access to your whole gdrive space.\n  - or `https://www.googleapis.com/auth/drive.appdata` if you want access an the OAuth 2.0 Playground appfolder.\n2. When calling the `CloudSyncExample`, provide which root you want to access. Must match the permissions you requested:\n   ```sh\n   ./CloudSyncExample --gdrive --root=\u003croot/appDataFolder\u003e --token=\u003caccess_token\u003e\n   ```\n\n##### Nextcloud\n\n1. Create an app-password for your session.\n2. Call `CloudSyncExample` with the domain, username and the app-password:\n   ```\n   ./CloudSyncExample --nextcloud --domain=https://\u003cyour_domain\u003e --username=\u003cusername\u003e --password=\u003capp-password\u003e\n   ```\n\n### Documentation\n\nThis project uses [Doxygen](https://www.doxygen.nl/index.html) for documentation.\n\nTo generate the docs, run `doxygen Doxyfile` or execute the `doxygen` target defined in the `CMakeLists.txt`.\n\n### CI/CD\n\nThis template uses [Github Actions](https://github.com/features/actions) for automating the release of a new library version.\n\n- The workflow `configureBuildTestCreateAndUpload.yaml` configures, builds, tests the library automatically on each push.\n  When a new release is created in Github, the resulting artifact is automatically uploaded to [a public  artifactory repository](https://gitlab.com/jothepro/libcloudsync/-/packages)\n- The workflow `publish-pages.yaml` automatically builds and publishes the documentation to [Github Pages](https://jothepro.github.io/libcloudsync/) when a new release is created in Github.\n\n### Coding Conventions\n\nThe C++ code should follow a derivation of [cppbestpractices code style](https://github.com/lefticus/cppbestpractices/blob/master/03-Style.md):\n\n- Types start with upper case and are CamelCase: `MyClass`\n- Functions and variables are snake_case: `my_method`\n- Constants are all upper case: `const double PI=3.14159265358979323;`\n- Name private data with a `m_` prefix to distinguish it from public data. `m_` stands for \"member\" data\n- Never use `using namespace` in a header file\n- `{}` are required for blocks.\n- Use `\"\"` for including local files, `\u003c\u003e` is reserved for system includes\n- Initialize member variables with the member initializer list\n- Always use namespaces\n- Use `.hpp` and `.cpp` for your file extensions\n- mark single parameter constructors as `explicit`, which requires them to be explicitly called.\n- do not provide any of the functions that the compiler can provide (copy constructor, copy assignment operator, \n  move constructor, move assignment operator, destructor) unless the class you are constructing does some novel form \n  of ownership.\n- Indentation is 4 spaces\n\n## Useful Links\n\n### API Documentation\n\n- [Dropbox](https://www.dropbox.com/developers/documentation/http/documentation)\n- [OneDrive](https://docs.microsoft.com/en-us/onedrive/developer/rest-api/)\n- [GDrive](https://developers.google.com/drive/api/v2/about-sdk)\n- [Nextcloud](https://docs.nextcloud.com/server/18/developer_manual/client_apis/WebDAV/index.html)\n\n### Getting developer tokens\n\n#### Dropbox\n\nVisit [`https://www.dropbox.com/developers/apps`](https://www.dropbox.com/developers/apps) and create a new app. \nIn the tab `Settings` under the section `OAuth 2` there is a button to create an access token. \nIt seems to be valid infinitely.\n\n#### OneDrive\n\nCreate an app in the [Azure Portal](https://portal.azure.com/). Copy the client-Id from the 'General'-Section.\nFollow [these](https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/graph-oauth?view=odsp-graph-online) instructions to obtain a token.\n\n#### GDrive\n\nGo to `https://developers.google.com/oauthplayground`, select the required scope, e.g. `https://www.googleapis.com/auth/drive.appdata` \nand let the tool do its job.\n\n#### Nextcloud\n\nDoes not support OAuth2, requires Username/Password login.\n\nIn your Nextcloud installation go to \u003ckbd\u003esettings\u003c/kbd\u003e \u003e  \u003ckbd\u003euser\u003c/kbd\u003e \u003e \u003ckbd\u003esecurity\u003c/kbd\u003e to create a specific app-password (recommended).\n\n## Roadmap\n\n- Implement equality operators for Cloud, Directory, File\n- Add tests for CURL wrapper (e.g. by going against a (mocked?) http server)\n- implementing support for big file upload/download (chunked upload/download)\n- Improve integration-test coverage\n- Improve unit-test coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/jothepro.github.io%2FlibCloudSync%2F","html_url":"https://awesome.ecosyste.ms/projects/jothepro.github.io%2FlibCloudSync%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/jothepro.github.io%2FlibCloudSync%2F/lists"}