A high-level, ergonomic crate for interacting with the UploadThing API

Overview

utapi-rs

A high-level, ergonomic Rust crate for interacting with the Uploadthing API.

Why?

If you're using Rust and want to use Uploadthing for file uploading, utapi-rs streamlines the process by providing a set of convenient functions mirroring Uploadthing's API.

Setup

Add the following to your Cargo.toml file to include utapi-rs as a dependency:

[dependencies]
utapi-rs = "0.1.0"

Usage

Below is a quick example of using utapi-rs to list files and delete a file.

use utapi_rs::{UtApi, ListFilesOpts, DeleteFileResponse};

#[tokio::main]
async fn main() {
    // Assume `new` attempts to retrieve the API key from an environment variable.
    let api = UtApi::new(None).expect("API key must be set");

    // List the files
    let opts = Some(ListFilesOpts {
        limit: Some(10), // Just as an example, limits the results to 10 files
        offset: None, // No offset for this example
    });

    match api.list_files(opts).await {
        Ok(file_response) => println!("Files: {:?}", file_response),
        Err(e) => eprintln!("Error listing files: {:?}", e),
    }

    // Delete a file
    match api.delete_files(vec!["file_key_to_delete".to_string()]).await {
        Ok(DeleteFileResponse { success }) => println!("Successfully deleted file: {}", success),
        Err(e) => eprintln!("Error deleting file: {:?}", e),
    }
}

Ensure that you have the tokio async runtime in your dependencies, as this library is designed to work asynchronously.

API Key

For security purposes, it is recommended not to hardcode the API key in your codebase. Instead, you should set it up as an environment variable:

# .env
UPLOADTHING_SECRET=sk_*************************

Make sure to load the .env file or export the environment variable for your runtime accordingly.

Contributing

Contributions are welcome! Please read our contributing guidelines for more details.

License

utapi-rs is released under the MIT License. See the LICENSE file for details.

You might also like...
A fast, simple TUI for interacting with systemd services and their logs
A fast, simple TUI for interacting with systemd services and their logs

systemctl-tui A fast, simple TUI for interacting with systemd services and their logs. systemctl-tui can quickly browse service status and logs, and s

An expressive Rust library for interacting with a cache.

Amnesia An expressive Rust library for interacting with a Cache. Features Driver-Based Architecture: Easily switch between different caching strategie

Solstice Flare - CLI Tool for interacting with Solana

🚧 WIP: This tool is in active development, and can experience breaking changes. For safety, it currently operates on Devnet by default Flare Flare is

Unopinionated low level API bindings focused on soundness, safety, and stronger types over raw FFI.

🔥 firehazard 🔥 Create a fire hazard by locking down your (Microsoft) Windows so nobody can escape (your security sandbox.) Unopinionated low level A

A high-performance Rust library designed to seamlessly integrate with the Discord API.

Rucord - Rust Library for Discord API Interactions Note: This library is currently under development and is not yet recommended for production use. Ov

High-Speed Memory Scanner & Analyzer with REST API.

memory-server High-Speed Memory Scanner & Analyzer with REST API. Usage iOS Jailbreaking of iphone is required. Place your PC and iphone in the same n

Prisma2D - Fast, API agnostic, software only 2D graphics crate in pure Rust.

Prisma2D: Ultra-fast CPU 2D graphics Prisma2D is a blazingly fast, efficient yet minimal crate for basic 2D graphics on the CPU. for Rust. With Prisma

List public items (public API) of library crates. Enables diffing public API between releases.

cargo-public-items List public items (the public API) of a Rust library crate by analyzing the rustdoc JSON of the crate. Automatically builds the rus

Api testing tool made with rust to use for api developement (Kind of Tui)
Api testing tool made with rust to use for api developement (Kind of Tui)

Api testing tool made with rust to use for api developement (Kind of Tui) This Rust project provides a simple yet powerful tool for making HTTP reques

Releases(v0.1.0)
  • v0.1.0(Feb 2, 2024)

Owner
Ivan Leon
I make computers talk with each other
Ivan Leon
high-level API for reaper-rs

rea-rs Easy to use ReaScript API. While reaper-rs is full-implemented at low-level, and, partially implemented at medium-level, on top of it (mostly,

Timofey Kazantsev 6 Dec 26, 2022
Rust crate for interacting with the Windows Packet Filter driver.

NDISAPI-RS NDISAPI-RS is a Rust crate for interacting with the Windows Packet Filter driver. It provides an easy-to-use, safe, and efficient interface

Vadim Smirnov 6 Jun 15, 2023
A command-line interface for interacting with the ChatGPT API from OpenAI

cligpt cligpt is a command-line interface for interacting with the ChatGPT API from OpenAI. With cligpt, you can quickly and easily generate text by s

Felipe S. S. Schneider 6 Apr 4, 2023
Ergonomic and precise error handling provided by error sets. Inspired by Zig's error set type.

Error Set Error Set simplifies error management by providing a streamlined method for defining errors and easily converting between them. Resultingly,

Henry 61 Jul 24, 2024
Rust Imaging Library's Python binding: A performant and high-level image processing library for Python written in Rust

ril-py Rust Imaging Library for Python: Python bindings for ril, a performant and high-level image processing library written in Rust. What's this? Th

Cryptex 13 Dec 6, 2022
High-performance, low-level framework for composing flexible web integrations

High-performance, low-level framework for composing flexible web integrations. Used mainly as a dependency of `barter-rs` project

Barter 8 Dec 28, 2022
Crates.io library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.

Crates.io library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.

consumet-rs 5 Aug 13, 2023
A high level DSL for Simplicity. This is a work in progress and is not yet ready for production use

A high level DSL for Simplicity. This is a work in progress and is not yet ready for production use. The language is designed to be simple and easy to use. It is inspired by rust syntax and is statically typed. The syntax will be extended in the future to support more features.

null 13 Oct 28, 2023
A lightweight and high-performance order-book designed to process level 2 and trades data. Available in Rust and Python

ninjabook A lightweight and high-performance order-book implemented in Rust, designed to process level 2 and trades data. Available in Python and Rust

Ninja Quant 134 Jul 22, 2024
Prototype for a CLI/Libary designed for interacting with NASA Open APIs with Rust.

Overview Voyager is a swiss army knife library for the NASA Open APIs. It is designed to bundle all the NASA APIs into a single package. Voyager can b

Ethan Gallucci 4 Aug 14, 2022