From 97784f0539c71b16c2acdfb0ef084ac0f11452cb Mon Sep 17 00:00:00 2001 From: Serhiy Barhamon Date: Sun, 15 Oct 2023 12:01:44 +0200 Subject: [PATCH] add context to post request --- src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 630b9b0..f5b301c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,14 +50,16 @@ impl Cloudinary { Source::Url(url) => Part::text(url.as_str().to_string()), }; let multipart = self.build_form_data(options).part("file", file); + let url = format!( + "https://api.cloudinary.com/v1_1/{}/image/upload", + self.cloud_name + ); let response = client - .post(format!( - "https://api.cloudinary.com/v1_1/{}/image/upload", - self.cloud_name - )) + .post(&url) .multipart(multipart) .send() - .await?; + .await + .context(format!("upload to {}", url))?; let text = response.text().await?; let json = serde_json::from_str(&text).context(format!("failed to parse:\n\n {}", text))?; Ok(json)