Yandex Disk C++ Client 1.0.0
Modern C++ client for Yandex.Disk REST API. Simple, lightweight, and static library for integrating Yandex.Disk cloud storage into C++ projects.
|
C++ client for Yandex.Disk REST API. More...
#include <YandexDiskClient.h>
Public Member Functions | |
YandexDiskClient (const std::string &oauth_token) | |
Constructor. Initializes client with OAuth token. | |
nlohmann::json | getQuotaInfo () |
Get disk quota information (total, used, trash). | |
std::string | formatQuotaInfo (const nlohmann::json &json) |
Format quota information as human-readable string. | |
nlohmann::json | getResourceList (const std::string &disk_path="/") |
Get list of files and folders at given path. | |
std::string | formatResourceList (const nlohmann::json &json) |
Format resource list as human-readable string. | |
std::string | getResourceInfo (const std::string &disk_path) |
Get detailed information about a file or folder. | |
bool | publish (const std::string &path) |
Publish a file or folder (make it public). | |
bool | unpublish (const std::string &disk_path) |
Unpublish a file or folder (remove public access). | |
std::string | getPublicDownloadLink (const std::string &disk_path) |
Get public download link for a published file or folder. | |
bool | uploadFile (const std::string &disk_dir, const std::string &local_path) |
Upload a local file to Yandex.Disk. | |
bool | downloadFile (const std::string &download_disk_path, const std::string &local_dir) |
Download a file from Yandex.Disk to local directory. | |
bool | uploadDirectory (const std::string &disk_path, const std::string &local_path) |
Recursively upload a local directory to Yandex.Disk. | |
bool | downloadDirectory (const std::string &disk_path, const std::string &local_path) |
Recursively download a directory from Yandex.Disk to local path. | |
bool | deleteFileOrDir (const std::string &disk_path) |
Delete a file or directory from Yandex.Disk. | |
bool | createDirectory (const std::string &disk_path) |
Create a directory on Yandex.Disk. | |
bool | moveFileOrDir (const std::string &from_path, const std::string &to_path, bool overwrite=false) |
Move or copy a file or directory on Yandex.Disk. | |
bool | renameFileOrDir (const std::string &disk_path, const std::string &new_name, bool overwrite=false) |
Rename a file or directory on Yandex.Disk. | |
bool | exists (const std::string &disk_path) |
Check if a file or directory exists on Yandex.Disk. | |
nlohmann::json | getTrashResourceList (const std::string &trash_path="trash:/") |
Get list of files and folders in Yandex.Disk trash. | |
std::string | formatTrashResourceList (const nlohmann::json &json) |
Format trash resource list as human-readable string. | |
bool | restoreFromTrash (const std::string &trash_path) |
Restore a file or directory from trash to its original location. | |
bool | deleteFromTrash (const std::string &trash_path) |
Permanently delete a file or directory from trash. | |
bool | emptyTrash () |
Empty the entire Yandex.Disk trash. | |
std::vector< std::string > | findTrashPathByName (const std::string &name) |
Find all resources in trash by name. | |
std::vector< std::string > | findResourcePathByName (const std::string &name, const std::string &start_path="/") |
Find all resources on disk by name (recursive). |
C++ client for Yandex.Disk REST API.
|
explicit |
Constructor. Initializes client with OAuth token.
oauth_token | Yandex.Disk OAuth token. |
bool YandexDiskClient::createDirectory | ( | const std::string & | disk_path | ) |
Create a directory on Yandex.Disk.
disk_path | Path to directory to create. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::deleteFileOrDir | ( | const std::string & | disk_path | ) |
Delete a file or directory from Yandex.Disk.
disk_path | Path to file or directory on Yandex.Disk. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::deleteFromTrash | ( | const std::string & | trash_path | ) |
Permanently delete a file or directory from trash.
trash_path | Path to resource in trash (from "path" field). |
std::runtime_error | on API/network error. |
bool YandexDiskClient::downloadDirectory | ( | const std::string & | disk_path, |
const std::string & | local_path ) |
Recursively download a directory from Yandex.Disk to local path.
disk_path | Path to directory on Yandex.Disk. |
local_path | Local directory to save contents. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::downloadFile | ( | const std::string & | download_disk_path, |
const std::string & | local_dir ) |
Download a file from Yandex.Disk to local directory.
download_disk_path | Path to file on Yandex.Disk. |
local_dir | Local directory to save the file. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::emptyTrash | ( | ) |
Empty the entire Yandex.Disk trash.
std::runtime_error | on API/network error. |
bool YandexDiskClient::exists | ( | const std::string & | disk_path | ) |
Check if a file or directory exists on Yandex.Disk.
disk_path | Path to file or directory. |
std::vector< std::string > YandexDiskClient::findResourcePathByName | ( | const std::string & | name, |
const std::string & | start_path = "/" ) |
Find all resources on disk by name (recursive).
name | Name of file or folder. |
start_path | Directory to start search from (default: root). |
std::vector< std::string > YandexDiskClient::findTrashPathByName | ( | const std::string & | name | ) |
Find all resources in trash by name.
name | Name of file or folder. |
std::string YandexDiskClient::formatQuotaInfo | ( | const nlohmann::json & | json | ) |
Format quota information as human-readable string.
json | JSON object from getQuotaInfo(). |
std::string YandexDiskClient::formatResourceList | ( | const nlohmann::json & | json | ) |
Format resource list as human-readable string.
json | JSON object from getResourceList(). |
std::string YandexDiskClient::formatTrashResourceList | ( | const nlohmann::json & | json | ) |
Format trash resource list as human-readable string.
json | JSON object from getTrashResourceList(). |
std::string YandexDiskClient::getPublicDownloadLink | ( | const std::string & | disk_path | ) |
Get public download link for a published file or folder.
disk_path | Path to file or folder on Yandex.Disk. |
std::runtime_error | if not published or on error. |
nlohmann::json YandexDiskClient::getQuotaInfo | ( | ) |
Get disk quota information (total, used, trash).
std::runtime_error | on API/network error. |
std::string YandexDiskClient::getResourceInfo | ( | const std::string & | disk_path | ) |
Get detailed information about a file or folder.
disk_path | Path to file or folder on Yandex.Disk. |
std::runtime_error | on API/network error. |
nlohmann::json YandexDiskClient::getResourceList | ( | const std::string & | disk_path = "/" | ) |
Get list of files and folders at given path.
disk_path | Path on Yandex.Disk (default: root "/"). |
std::runtime_error | on API/network error. |
nlohmann::json YandexDiskClient::getTrashResourceList | ( | const std::string & | trash_path = "trash:/" | ) |
Get list of files and folders in Yandex.Disk trash.
trash_path | Path in trash (default: "trash:/"). |
std::runtime_error | on API/network error. |
bool YandexDiskClient::moveFileOrDir | ( | const std::string & | from_path, |
const std::string & | to_path, | ||
bool | overwrite = false ) |
Move or copy a file or directory on Yandex.Disk.
from_path | Source path. |
to_path | Destination path. |
overwrite | Overwrite if destination exists. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::publish | ( | const std::string & | path | ) |
Publish a file or folder (make it public).
path | Path to file or folder on Yandex.Disk. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::renameFileOrDir | ( | const std::string & | disk_path, |
const std::string & | new_name, | ||
bool | overwrite = false ) |
Rename a file or directory on Yandex.Disk.
disk_path | Path to file or directory. |
new_name | New name. |
overwrite | Overwrite if destination exists. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::restoreFromTrash | ( | const std::string & | trash_path | ) |
Restore a file or directory from trash to its original location.
trash_path | Path to resource in trash (from "path" field). |
std::runtime_error | on API/network error. |
bool YandexDiskClient::unpublish | ( | const std::string & | disk_path | ) |
Unpublish a file or folder (remove public access).
disk_path | Path to file or folder on Yandex.Disk. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::uploadDirectory | ( | const std::string & | disk_path, |
const std::string & | local_path ) |
Recursively upload a local directory to Yandex.Disk.
disk_path | Destination directory on Yandex.Disk. |
local_path | Local directory to upload. |
std::runtime_error | on API/network error. |
bool YandexDiskClient::uploadFile | ( | const std::string & | disk_dir, |
const std::string & | local_path ) |
Upload a local file to Yandex.Disk.
disk_dir | Destination directory or file path on Yandex.Disk. |
local_path | Path to local file. |
std::runtime_error | on API/network error. |