7 releases

0.2.1 Sep 1, 2020
0.2.0 Aug 19, 2020
0.1.4 Jul 24, 2020

#25 in #file-upload

MIT license

76KB
1.5K SLoC

Rust API client for Uploadcare

License rest Documentation Crates

Uploadcare Rust API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.

Requirements

rustc 1.43
cargo 1.43

Installation

[dependencies]
uploadcare = "^0.1"

Feature Flags

By default the full is enabled (REST and Upload API).

To reduce code size, disable default features and enable just the APIs you use:

# Example: REST API only
uploadcare = { version = "*", default-features = false, features = ["rest"] }

Configuration

use ucare;
use ucare::file;
use ucare::upload;

let creds = ucare::apicreds {
    secret_key: "your_project_secret_key",
    pub_key: "your_project_pub_key",
};

// creating rest client
let config = ucare::RestConfig {
    sign_based_auth: true,
    api_version: ucare::RestApiVersion::v06,
};
let rest_client = ucare::RestClient::new(config, creds).unwrap();

// creating upload client
let config = ucare::UploadConfig {
    sign_based_upload: true,
};
let upload_client = ucare::UploadClient::new(config, creds).unwrap();

Usage

For a comprehensive list of examples, check out the API documentation. Below are a few usage examples:

let file_svc = file::new_svc(&rest_client);

let file_id = "b7c1bf20-0f4c-4ba4-b3a8-a74ebc663752";
let file_info = file_svc.info(file_id).unwrap();
println!("{}: {:?}", file_id, file_info);

let upload_svc = upload::new_svc(&upload_client);

let params = upload::FileParams {
    path: "/path/to/file".to_string(),
    name: "filename".to_string(),
    to_store: Some(upload::ToStore::Auto),
};
let file = upload_svc.file(params).unwrap();
println!("uploaded: {:?}", file.id);

Rust API client documentation
Uploadcare documentation
Upload API reference
REST API reference
Changelog
Contributing guide
Security policy
Support

Dependencies

~8–13MB
~247K SLoC