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