Uploadcare-Rust

rest Documentation Crates License

Rust library for accessing Uploadcare API https://uploadcare.com/

Table of Contents

Requirements

rustc 1.43
cargo 1.43

Installation

toml [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:

```toml

Example: REST API only

uploadcare = { version = "*", default-features = false, features = ["rest"] } ```

Configuration

```rust use ucare; use ucare::file; use ucare::upload;

let creds = ucare::apicreds { secretkey: "yourprojectsecretkey", pubkey: "yourprojectpubkey", };

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

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

Usage

```rust let filesvc = file::newsvc(&rest_client);

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

let uploadsvc = upload::newsvc(&upload_client);

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

```


MIT License. Copyright (c) 2020 Uploadcare