mirror of
https://github.com/MedzikUser/imgurs
synced 2024-08-15 00:03:19 +00:00
fix(0x0): fix builder error
This commit is contained in:
parent
312d9cce19
commit
c6b6bd1af7
3 changed files with 28 additions and 7 deletions
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -1011,6 +1011,16 @@ version = "0.3.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.3.7"
|
||||
|
@ -1463,6 +1473,7 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"log",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustls",
|
||||
|
@ -1943,6 +1954,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.8"
|
||||
|
|
|
@ -33,7 +33,7 @@ validator = "0.16.0"
|
|||
thiserror = "1.0.32"
|
||||
serde_json = "1.0.85"
|
||||
serde = { version = "1.0.144", features = ["derive"] }
|
||||
reqwest = { version = "0.11.11", default-features = false, features = ["json", "rustls-tls"] }
|
||||
reqwest = { version = "0.11.11", default-features = false, features = ["json", "rustls-tls", "multipart"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.20.1", features = ["macros", "rt-multi-thread"] }
|
||||
|
|
|
@ -38,14 +38,11 @@ impl NullPointer {
|
|||
/// }
|
||||
/// ```
|
||||
pub async fn upload(&self, path: &str) -> Result<String> {
|
||||
// create http form (hashmap)
|
||||
let mut form = HashMap::new();
|
||||
let mut bytes = Vec::new();
|
||||
|
||||
// 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)?;
|
||||
|
||||
form.insert("file", bytes);
|
||||
bytes = std::fs::read(path)?;
|
||||
}
|
||||
// validate url adress
|
||||
else {
|
||||
|
@ -65,7 +62,11 @@ impl NullPointer {
|
|||
format!("Imgur/{:?}", env!("CARGO_PKG_VERSION")),
|
||||
);
|
||||
|
||||
req = req.form(&form);
|
||||
let part = reqwest::multipart::Part::bytes(bytes);
|
||||
|
||||
let form = reqwest::multipart::Form::new().part("file", part);
|
||||
|
||||
req = req.multipart(form);
|
||||
|
||||
// build Request
|
||||
let req = req.build()?;
|
||||
|
|
Loading…
Reference in a new issue