Skip to content

Commit e07c609

Browse files
committed
feat(cli): add zip upload support for add_skill in Rust CLI
- Add smart dual-mode upload in add_skill() (same as add_resource) - Fix missing auth headers in upload_temp_file() - Reuse build_headers() to avoid code duplication
1 parent 22ca18e commit e07c609

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

crates/ov_cli/src/client.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ impl HttpClient {
100100

101101
let form = reqwest::multipart::Form::new().part("file", part);
102102

103+
let mut headers = self.build_headers();
104+
headers.remove(reqwest::header::CONTENT_TYPE);
105+
103106
let response = self
104107
.http
105108
.post(&url)
109+
.headers(headers)
106110
.multipart(form)
107111
.send()
108112
.await
@@ -460,12 +464,26 @@ impl HttpClient {
460464
wait: bool,
461465
timeout: Option<f64>,
462466
) -> Result<serde_json::Value> {
463-
let body = serde_json::json!({
464-
"data": data,
465-
"wait": wait,
466-
"timeout": timeout,
467-
});
468-
self.post("/api/v1/skills", &body).await
467+
let path_obj = Path::new(data);
468+
469+
if path_obj.exists() && path_obj.is_dir() && !self.is_local_server() {
470+
let zip_file = self.zip_directory(path_obj)?;
471+
let temp_path = self.upload_temp_file(zip_file.path()).await?;
472+
473+
let body = serde_json::json!({
474+
"temp_path": temp_path,
475+
"wait": wait,
476+
"timeout": timeout,
477+
});
478+
self.post("/api/v1/skills", &body).await
479+
} else {
480+
let body = serde_json::json!({
481+
"data": data,
482+
"wait": wait,
483+
"timeout": timeout,
484+
});
485+
self.post("/api/v1/skills", &body).await
486+
}
469487
}
470488

471489
// ============ Relation Methods ============

0 commit comments

Comments
 (0)