Skip to content

Commit

Permalink
add context to post request
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurk committed Oct 15, 2023
1 parent 15130fb commit 97784f0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 97784f0

Please sign in to comment.