fix release attachments
This commit is contained in:
parent
79fb779030
commit
a2ff083f71
5 changed files with 36 additions and 9 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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue