From 1fb6cfd69c9d667e2cdf9025c284d81c74c3735f Mon Sep 17 00:00:00 2001 From: Mahdi Robatipoor Date: Wed, 28 Feb 2024 23:02:45 +0330 Subject: [PATCH] add show_upload_response --- cli/src/command.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index 396a53d..618fd2c 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -1,7 +1,7 @@ use sdk::{ dto::{ request::UploadQueryParam, - response::{ApiResponseResult, BodyResponseError, MessageResponse}, + response::{ApiResponseResult, BodyResponseError, MessageResponse, UploadResponse}, FileUrlPath, }, util::file::{add_extension, rm_extra_extension}, @@ -58,8 +58,15 @@ pub async fn upload(args: UploadArguments) { client.upload_from(&source_file, ¶m, args.auth).await } .unwrap(); + show_upload_response(resp, args.output); + if args.key_nonce.is_some() { + tokio::fs::remove_file(source_file).await.unwrap(); + }; +} + +fn show_upload_response(resp: ApiResponseResult, output: UploadOutput) { match resp { - ApiResponseResult::Ok(resp) => match args.output { + ApiResponseResult::Ok(resp) => match output { UploadOutput::Json => { println!("{}", serde_json::to_string(&resp).unwrap()); } @@ -76,9 +83,6 @@ pub async fn upload(args: UploadArguments) { }, ApiResponseResult::Err(err) => print_response_err(&err), } - if args.key_nonce.is_some() { - tokio::fs::remove_file(source_file).await.unwrap(); - }; } pub async fn download(