From e8b3591c102227c3bef0ff8959fd40d7636b8a10 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Wed, 9 Jul 2025 16:01:54 +0200 Subject: [PATCH] Use new API v1 path for uploads --- src/api.rs | 14 +++++++------- src/cmd/upload.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api.rs b/src/api.rs index b88e84c..aac7c03 100644 --- a/src/api.rs +++ b/src/api.rs @@ -10,7 +10,7 @@ use url::Url; use crate::config::Config; #[derive(Debug, Deserialize)] -pub struct UploadAsciicastResponse { +pub struct RecordingResponse { pub url: String, pub message: Option, } @@ -33,11 +33,11 @@ pub fn get_auth_url(config: &Config) -> Result { Ok(url) } -pub async fn upload_asciicast(path: &str, config: &Config) -> Result { +pub async fn create_recording(path: &str, config: &Config) -> Result { let server_url = &config.get_server_url()?; let install_id = config.get_install_id()?; - let response = upload_request(server_url, path, install_id) + let response = create_recording_request(server_url, path, install_id) .await? .send() .await?; @@ -48,18 +48,18 @@ pub async fn upload_asciicast(path: &str, config: &Config) -> Result().await?) + Ok(response.json::().await?) } -async fn upload_request( +async fn create_recording_request( server_url: &Url, path: &str, install_id: String, ) -> Result { let client = Client::new(); let mut url = server_url.clone(); - url.set_path("api/asciicasts"); - let form = Form::new().file("asciicast", path).await?; + url.set_path("api/v1/recordings"); + let form = Form::new().file("file", path).await?; Ok(client .post(url) diff --git a/src/cmd/upload.rs b/src/cmd/upload.rs index fa561b9..24ea5cf 100644 --- a/src/cmd/upload.rs +++ b/src/cmd/upload.rs @@ -14,7 +14,7 @@ impl cli::Upload { async fn do_run(self) -> Result<()> { let config = Config::new(self.server_url.clone())?; let _ = asciicast::open_from_path(&self.file)?; - let response = api::upload_asciicast(&self.file, &config).await?; + let response = api::create_recording(&self.file, &config).await?; println!("{}", response.message.unwrap_or(response.url)); Ok(())