@@ -103,7 +103,7 @@ def request_token(data: dict[str, str]) -> str:
103
103
@interrupt_handler
104
104
def upload_progress (chunk , progress_bar : tqdm ):
105
105
progress_bar .update (chunk )
106
-
106
+
107
107
@interrupt_handler
108
108
def _ask_for_init (file_name : str = None ) -> str :
109
109
ask_for_init (file_name )
@@ -112,31 +112,30 @@ def _ask_for_init(file_name: str=None) -> str:
112
112
def main ():
113
113
argcomplete .autocomplete (command_parser )
114
114
args = command_parser .parse_args ()
115
-
115
+
116
116
if not args .command and not args .file :
117
117
menu_command = main_menu ()
118
118
if menu_command .command == 'upload_2' :
119
119
args .command = 'upload'
120
120
args .file = menu_command .file
121
121
else :
122
122
args .command = menu_command .command
123
-
123
+
124
124
if args .command not in ['login' , 'logout' , 'upload' , 'init' , 'validate' ]:
125
125
args .file = args .command
126
126
args .command = 'upload'
127
127
128
128
if args .file and not args .command :
129
129
args .command = 'upload'
130
-
130
+
131
131
if args .command == 'init' :
132
132
_ask_for_init ()
133
133
exit (0 )
134
-
134
+
135
135
if args .command == 'validate' :
136
136
print (warn ("该功能尚未实现" ))
137
137
exit (0 )
138
138
139
-
140
139
config_dir = pathlib .Path .home () / ".config" / "byrdocs"
141
140
if not config_dir .exists ():
142
141
config_dir .mkdir (parents = True )
@@ -160,7 +159,7 @@ def login(token=None):
160
159
print (info ("请在浏览器中访问以下链接进行登录:" ))
161
160
print ("\t " + login_data ["loginURL" ])
162
161
token = request_token (login_data )
163
-
162
+
164
163
with token_path .open ("w" ) as f :
165
164
f .write (token )
166
165
print (info (f"登录成功,凭证已保存到 { token_path .absolute ()} " ))
@@ -255,8 +254,9 @@ def login(token=None):
255
254
progress_bar = tqdm (total = file_size , unit = 'B' , unit_scale = True , desc = "Uploading" )
256
255
257
256
# https://blog.csdn.net/weixin_44123540/article/details/118492260
258
- GB = 1024 ** 3
259
- upload_config = boto3 .s3 .transfer .TransferConfig (multipart_threshold = 2 * GB )
257
+ # 对于上传 100MB 的文件会有限制,需要分块上传
258
+ MB = 1024 ** 2
259
+ upload_config = boto3 .s3 .transfer .TransferConfig (multipart_threshold = 100 * MB , multipart_chunksize = 50 * MB )
260
260
261
261
try :
262
262
s3_client .upload_file (
@@ -275,7 +275,7 @@ def login(token=None):
275
275
UploadHistory ().add (pathlib .Path (file ).name , md5 , time ())
276
276
print (info ("文件上传成功!" ))
277
277
print (f"\t 文件地址: { baseURL } /files/{ new_filename } " )
278
-
278
+
279
279
try :
280
280
if ask_for_confirmation ("是否立即为该文件录入元信息?" ):
281
281
_ask_for_init (new_filename )
0 commit comments