mirror of https://github.com/MedzikUser/imgurs
Fix deprecation warning of base64 crate.
See: https://github.com/M3DZIK/imgurs/actions/runs/3871046426/jobs/6598478600
This commit is contained in:
parent
0398f7f675
commit
27eb41a48b
|
@ -59,12 +59,14 @@ impl ImgurClient {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub async fn upload_image(&self, path: &str) -> Result<ImageInfo> {
|
pub async fn upload_image(&self, path: &str) -> Result<ImageInfo> {
|
||||||
|
use base64::prelude::{Engine, BASE64_STANDARD};
|
||||||
|
|
||||||
let mut image = path.to_string();
|
let mut image = path.to_string();
|
||||||
|
|
||||||
// check if the specified file exists if not then check if it is a url
|
// check if the specified file exists if not then check if it is a url
|
||||||
if std::path::Path::new(path).exists() {
|
if std::path::Path::new(path).exists() {
|
||||||
let bytes = std::fs::read(path)?;
|
let bytes = std::fs::read(path)?;
|
||||||
image = base64::encode(bytes)
|
image = BASE64_STANDARD.encode(bytes)
|
||||||
}
|
}
|
||||||
// validate url adress
|
// validate url adress
|
||||||
else if !validator::validate_url(path) {
|
else if !validator::validate_url(path) {
|
||||||
|
|
Loading…
Reference in New Issue