Crates.io | uploadcare |
lib.rs | uploadcare |
version | 0.2.1 |
source | src |
created_at | 2020-07-09 14:38:41.038925 |
updated_at | 2020-09-01 12:19:31.933108 |
description | Rust client for the Uploadcare REST and Upload API |
homepage | https://github.com/uploadcare/uploadcare-rust |
repository | https://github.com/uploadcare/uploadcare-rust |
max_upload_size | |
id | 262908 |
size | 77,220 |
Uploadcare Rust API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
rustc 1.43
cargo 1.43
[dependencies]
uploadcare = "^0.1"
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"] }
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();
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