Fix deprecation warning of base64 crate.

See: https://github.com/M3DZIK/imgurs/actions/runs/3871046426/jobs/6598478600
This commit is contained in:
Andre Julius 2023-04-03 14:13:05 +02:00 committed by Oskar
parent 0398f7f675
commit e9a7108f90
1 changed files with 3 additions and 1 deletions

View File

@ -59,12 +59,14 @@ impl ImgurClient {
/// }
/// ```
pub async fn upload_image(&self, path: &str) -> Result<ImageInfo> {
use base64::prelude::{Engine, BASE64_STANDARD};
let mut image = path.to_string();
// check if the specified file exists if not then check if it is a url
if std::path::Path::new(path).exists() {
let bytes = std::fs::read(path)?;
image = base64::encode(bytes)
image = BASE64_STANDARD.encode(bytes)
}
// validate url adress
else if !validator::validate_url(path) {