Crates.io | imgbb |
lib.rs | imgbb |
version | 1.2.1 |
source | src |
created_at | 2023-06-29 15:51:18.423393 |
updated_at | 2023-07-06 14:10:11.746968 |
description | ImgBB API wrapper for Rust |
homepage | |
repository | https://github.com/phusitsom/imgbb-rs |
max_upload_size | |
id | 903411 |
size | 46,957 |
ImgBB API wrapper for rust
use imgbb::ImgBB;
use tokio;
#[tokio::main]
async fn main() {
let imgbb = ImgBB::new("<API KEY>");
let res = match imgbb.upload_file_with_expiration("<PATH>", <SECONDS>).await {
Ok(res) => res,
Err(err) => {
println!("{}", err);
return;
}
};
println!("{:#?}", res);
}
use imgbb::ImgBB;
use tokio;
#[tokio::main]
async fn main() {
let imgbb = ImgBB::new("<API KEY>");
let ul = imgbb
.read_file("<PATH>").expect("Unable to read file")
.expiration(<SECONDS>);
let res = match ul.upload().await {
Ok(res) => res,
Err(err) => {
println!("{}", err);
return;
}
};
println!("{:#?}", res);
}
imgbb.read_file("PATH").expect("Unable to read file").upload().await
// or
imgbb.upload_file("PATH").await
AsRef<u8>
) imgbb.read_bytes(&[u8]).upload().await
// or
imgbb.upload_bytes(&[u8]).await
imgbb.read_base64("BASE64").upload().await
// or
imgbb.upload_base64("BASE64").await
imgbb-rs is licensed under the GNU GPL v3.0