Skip to main content

Crate cyberdrop_client

Crate cyberdrop_client 

Source
Expand description

Cyberdrop API client.

This crate provides a small, async wrapper around a subset of Cyberdrop’s HTTP API. It is built on reqwest and is intended to be copy-paste friendly in CLI tools and simple services.

§Quickstart

Authenticate, then call endpoints that require a token:

use cyberdrop_client::CyberdropClient;
use std::path::Path;

// 1) Create an unauthenticated client.
let client = CyberdropClient::new()?;

// 2) Exchange credentials for a token.
let token = client.login("username", "password").await?;

// 3) Use a cloned client that includes the token on authenticated requests.
let authed = client.with_auth_token(token.into_string());
let albums = authed.list_albums().await?;
println!("albums: {}", albums.len());

// 4) Create an album and upload a file into it.
let album_id = authed
    .create_album("my uploads", Some("created by cyberdrop-client"))
    .await?;
let uploaded = authed
    .upload_file(Path::new("path/to/file.jpg"), Some(album_id))
    .await?;
println!("uploaded {} -> {}", uploaded.name, uploaded.url);

Note: upload_file streams smaller files and reads larger files in chunks.

§Authentication

Authenticated endpoints use an HTTP header named token (not an Authorization: Bearer ... header). Methods that require authentication return CyberdropError::MissingAuthToken if no token is configured.

§Timeouts, Retries, Polling

  • Timeouts: The client uses a single 30 second request timeout. Timeout failures surface as CyberdropError::Http (from reqwest).
  • Retries: This crate does not implement retries, backoff, or idempotency safeguards. If you need retries, add them at the call site.
  • Polling: This crate does not poll for eventual consistency. Methods return once the HTTP request/response completes.

§Error Model

Higher-level API methods (for example, CyberdropClient::list_albums) treat non-2xx HTTP responses as errors:

External system failures are surfaced as:

Structs§

Album
Album metadata as returned by the Cyberdrop API.
AlbumFile
File metadata as returned by the album listing endpoint.
AlbumFiles
Files returned by the album listing endpoint.
AuthToken
Authentication token returned by crate::CyberdropClient::login and crate::CyberdropClient::register.
CyberdropClient
Async HTTP client for a subset of Cyberdrop endpoints.
EditAlbumResult
Result of editing an album via crate::CyberdropClient::edit_album.
Permissions
Permission flags associated with a user/token verification response.
TokenVerification
Result of verifying a token via crate::CyberdropClient::verify_token.
UploadProgress
Upload progress information emitted during file uploads.
UploadedFile
Uploaded file metadata returned by crate::CyberdropClient::upload_file.

Enums§

CyberdropError
Errors returned by this crate.