1
- use std:: path:: { Path , PathBuf } ;
2
-
3
- use base64:: { engine:: general_purpose:: STANDARD , Engine } ;
4
1
use sdk:: {
5
2
dto:: {
6
- request:: { QrCodeFormat , UploadQueryParam } ,
3
+ request:: UploadQueryParam ,
7
4
response:: { ApiResponseResult , BodyResponseError , MessageResponse } ,
8
5
FileUrlPath ,
9
6
} ,
10
7
util:: file:: { add_extension, rm_extra_extension} ,
11
8
} ;
9
+ use std:: path:: { Path , PathBuf } ;
12
10
use url:: Url ;
13
11
14
12
use crate :: { args:: UploadOutput , client:: CommandLineClient , util:: crypto:: KeyNonce } ;
@@ -44,25 +42,20 @@ pub async fn upload(args: UploadArguments) {
44
42
. await
45
43
. unwrap ( ) ;
46
44
}
47
- let qr_code_format = if args. output == UploadOutput :: Json || args. output == UploadOutput :: QrCode {
48
- Some ( QrCodeFormat :: Text )
49
- } else {
50
- None
51
- } ;
52
- let query = UploadQueryParam {
45
+ let param = UploadQueryParam {
53
46
max_download : args. max_download ,
54
47
code_length : args. code_length ,
55
48
expire_secs : args. expire ,
56
49
delete_manually : args. delete_manually ,
57
- qr_code_format,
50
+ qr_code_format : None ,
58
51
} ;
59
52
let client = CommandLineClient :: new ( args. server_addr ) ;
60
53
let ( _, resp) = if args. progress_bar {
61
54
client
62
- . upload_with_progress_bar ( & source_file, & query , args. auth )
55
+ . upload_with_progress_bar ( & source_file, & param , args. auth )
63
56
. await
64
57
} else {
65
- client. upload_from ( & source_file, & query , args. auth ) . await
58
+ client. upload_from ( & source_file, & param , args. auth ) . await
66
59
}
67
60
. unwrap ( ) ;
68
61
match resp {
@@ -71,10 +64,8 @@ pub async fn upload(args: UploadArguments) {
71
64
println ! ( "{}" , serde_json:: to_string( & resp) . unwrap( ) ) ;
72
65
}
73
66
UploadOutput :: QrCode => {
74
- println ! (
75
- "{}" ,
76
- std:: str :: from_utf8( & STANDARD . decode( resp. qr_code. unwrap( ) ) . unwrap( ) ) . unwrap( )
77
- ) ;
67
+ let qr_code = sdk:: util:: qr_code:: generate_text_qr_code ( & resp. url ) . unwrap ( ) ;
68
+ println ! ( "{qr_code}" ) ;
78
69
}
79
70
UploadOutput :: Url => {
80
71
println ! ( "{}" , resp. url) ;
0 commit comments