allow uploading private demos

This commit is contained in:
Robin Appelman 2025-05-03 16:20:26 +02:00
commit ef7e590be0
5 changed files with 502 additions and 343 deletions

View file

@ -377,12 +377,39 @@ impl ApiClient {
red: String,
blue: String,
key: String,
) -> Result<u32, Error> {
self.upload_maybe_private_demo(file_name, body, red, blue, key, false)
.await
}
#[instrument(skip(body))]
pub async fn upload_private_demo(
&self,
file_name: String,
body: Vec<u8>,
red: String,
blue: String,
key: String,
) -> Result<u32, Error> {
self.upload_maybe_private_demo(file_name, body, red, blue, key, true)
.await
}
async fn upload_maybe_private_demo(
&self,
file_name: String,
body: Vec<u8>,
red: String,
blue: String,
key: String,
private: bool,
) -> Result<u32, Error> {
let form = multipart::Form::new()
.text("red", red)
.text("blue", blue)
.text("name", file_name)
.text("key", key);
.text("key", key)
.text("private", if private { "1" } else { "0" });
let file = multipart::Part::bytes(body)
.file_name("demo.dem")