diff options
author | Cyborus <cyborus@cyborus.xyz> | 2023-12-11 20:31:52 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2023-12-11 21:52:45 +0100 |
commit | a2ff083f715f22a49ebbf3d40aca8373174f5448 (patch) | |
tree | c5fe2622a69c2b5ce108cf40026aa3cfcaa7405f /src | |
parent | test editing release (diff) | |
download | forgejo-api-a2ff083f715f22a49ebbf3d40aca8373174f5448.tar.xz forgejo-api-a2ff083f715f22a49ebbf3d40aca8373174f5448.zip |
fix release attachments
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/repository.rs | 7 |
2 files changed, 8 insertions, 7 deletions
@@ -104,13 +104,13 @@ impl Forgejo { self.execute(request).await } - async fn post_form<T: Serialize, U: DeserializeOwned>( + async fn post_multipart<T: DeserializeOwned>( &self, path: &str, - body: &T, - ) -> Result<U, ForgejoError> { + body: reqwest::multipart::Form, + ) -> Result<T, ForgejoError> { let url = self.url.join("api/v1/").unwrap().join(path).unwrap(); - let request = self.client.post(url).form(body).build()?; + let request = self.client.post(url).multipart(body).build()?; self.execute(request).await } diff --git a/src/repository.rs b/src/repository.rs index 4d89ec9..8b063a0 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -140,11 +140,12 @@ impl Forgejo { repo: &str, id: u64, name: &str, - file: &[u8], + file: Vec<u8>, ) -> Result<Attachment, ForgejoError> { - self.post_form( + self.post_multipart( &format!("repos/{owner}/{repo}/releases/{id}/assets?name={name}"), - &file, + reqwest::multipart::Form::new() + .part("attachment", reqwest::multipart::Part::bytes(file).file_name("file").mime_str("*/*").unwrap()), ) .await } |