@@ -433,30 +433,63 @@ impl HttpClient {
433433 directly_upload_media : bool ,
434434 ) -> Result < serde_json:: Value > {
435435 let path_obj = Path :: new ( path) ;
436-
437- // Check if it's a local directory and not a local server
438- if path_obj. exists ( ) && path_obj. is_dir ( ) && !self . is_local_server ( ) {
439- // Zip the directory
440- let zip_file = self . zip_directory ( path_obj) ?;
441- let temp_path = self . upload_temp_file ( zip_file. path ( ) ) . await ?;
442-
443- let body = serde_json:: json!( {
444- "temp_path" : temp_path,
445- "target" : target,
446- "reason" : reason,
447- "instruction" : instruction,
448- "wait" : wait,
449- "timeout" : timeout,
450- "strict" : strict,
451- "ignore_dirs" : ignore_dirs,
452- "include" : include,
453- "exclude" : exclude,
454- "directly_upload_media" : directly_upload_media,
455- } ) ;
456-
457- self . post ( "/api/v1/resources" , & body) . await
436+
437+ if path_obj. exists ( ) && !self . is_local_server ( ) {
438+ if path_obj. is_dir ( ) {
439+ let zip_file = self . zip_directory ( path_obj) ?;
440+ let temp_path = self . upload_temp_file ( zip_file. path ( ) ) . await ?;
441+
442+ let body = serde_json:: json!( {
443+ "temp_path" : temp_path,
444+ "target" : target,
445+ "reason" : reason,
446+ "instruction" : instruction,
447+ "wait" : wait,
448+ "timeout" : timeout,
449+ "strict" : strict,
450+ "ignore_dirs" : ignore_dirs,
451+ "include" : include,
452+ "exclude" : exclude,
453+ "directly_upload_media" : directly_upload_media,
454+ } ) ;
455+
456+ self . post ( "/api/v1/resources" , & body) . await
457+ } else if path_obj. is_file ( ) {
458+ let temp_path = self . upload_temp_file ( path_obj) . await ?;
459+
460+ let body = serde_json:: json!( {
461+ "temp_path" : temp_path,
462+ "target" : target,
463+ "reason" : reason,
464+ "instruction" : instruction,
465+ "wait" : wait,
466+ "timeout" : timeout,
467+ "strict" : strict,
468+ "ignore_dirs" : ignore_dirs,
469+ "include" : include,
470+ "exclude" : exclude,
471+ "directly_upload_media" : directly_upload_media,
472+ } ) ;
473+
474+ self . post ( "/api/v1/resources" , & body) . await
475+ } else {
476+ let body = serde_json:: json!( {
477+ "path" : path,
478+ "target" : target,
479+ "reason" : reason,
480+ "instruction" : instruction,
481+ "wait" : wait,
482+ "timeout" : timeout,
483+ "strict" : strict,
484+ "ignore_dirs" : ignore_dirs,
485+ "include" : include,
486+ "exclude" : exclude,
487+ "directly_upload_media" : directly_upload_media,
488+ } ) ;
489+
490+ self . post ( "/api/v1/resources" , & body) . await
491+ }
458492 } else {
459- // Regular case - use path directly
460493 let body = serde_json:: json!( {
461494 "path" : path,
462495 "target" : target,
@@ -470,7 +503,7 @@ impl HttpClient {
470503 "exclude" : exclude,
471504 "directly_upload_media" : directly_upload_media,
472505 } ) ;
473-
506+
474507 self . post ( "/api/v1/resources" , & body) . await
475508 }
476509 }
@@ -483,16 +516,34 @@ impl HttpClient {
483516 ) -> Result < serde_json:: Value > {
484517 let path_obj = Path :: new ( data) ;
485518
486- if path_obj. exists ( ) && path_obj. is_dir ( ) && !self . is_local_server ( ) {
487- let zip_file = self . zip_directory ( path_obj) ?;
488- let temp_path = self . upload_temp_file ( zip_file. path ( ) ) . await ?;
489-
490- let body = serde_json:: json!( {
491- "temp_path" : temp_path,
492- "wait" : wait,
493- "timeout" : timeout,
494- } ) ;
495- self . post ( "/api/v1/skills" , & body) . await
519+ if path_obj. exists ( ) && !self . is_local_server ( ) {
520+ if path_obj. is_dir ( ) {
521+ let zip_file = self . zip_directory ( path_obj) ?;
522+ let temp_path = self . upload_temp_file ( zip_file. path ( ) ) . await ?;
523+
524+ let body = serde_json:: json!( {
525+ "temp_path" : temp_path,
526+ "wait" : wait,
527+ "timeout" : timeout,
528+ } ) ;
529+ self . post ( "/api/v1/skills" , & body) . await
530+ } else if path_obj. is_file ( ) {
531+ let temp_path = self . upload_temp_file ( path_obj) . await ?;
532+
533+ let body = serde_json:: json!( {
534+ "temp_path" : temp_path,
535+ "wait" : wait,
536+ "timeout" : timeout,
537+ } ) ;
538+ self . post ( "/api/v1/skills" , & body) . await
539+ } else {
540+ let body = serde_json:: json!( {
541+ "data" : data,
542+ "wait" : wait,
543+ "timeout" : timeout,
544+ } ) ;
545+ self . post ( "/api/v1/skills" , & body) . await
546+ }
496547 } else {
497548 let body = serde_json:: json!( {
498549 "data" : data,
0 commit comments