pindo 4.7.8 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pindo/client/pgyeruploadclient.rb +14 -29
- data/lib/pindo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a76bb1d95b970919b4b386f52841ddc4cb21ac22a7b5d433c7fcc88b6030da
|
4
|
+
data.tar.gz: e0f0eb7ec08a2fca3489b0d469fe23eaa0f34ea9d88bcb209b50df822f42e406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d95421e56c75ed51b5d75b7e84aa2e7dba6c566379d6cc23e3966aa616dc15f0c433552b5963c04ae36f488891dc80b1f2ac8b79f0069d166daaaf59c942bd0
|
7
|
+
data.tar.gz: a3c6c60f5398b336f17a79bff657a4eb0b28882328828fc05507bbe38a03e4785f455492dffd0800df788d686351ecc3376a88e8e69bd3e2268337417571f2f6
|
@@ -94,14 +94,12 @@ module Pindo
|
|
94
94
|
|
95
95
|
upload_path_key = upload_path + file_uuid + extension
|
96
96
|
|
97
|
-
task_num =
|
97
|
+
task_num = 10
|
98
98
|
|
99
99
|
puts "文件路径: #{@upload_binary_file}"
|
100
100
|
puts "文件大小: #{total_m}M"
|
101
101
|
puts "上传路径: #{upload_path_key}"
|
102
102
|
puts "切片大小: 5 MB"
|
103
|
-
puts "最大线程数: #{task_num}"
|
104
|
-
puts
|
105
103
|
|
106
104
|
upload_result = nil
|
107
105
|
|
@@ -110,7 +108,17 @@ module Pindo
|
|
110
108
|
|
111
109
|
upload_id= result_data["data"]["uploadId"]
|
112
110
|
@upload_params_list = result_data["data"]["uploadParamsList"]
|
111
|
+
task_num = @upload_params_list.length
|
112
|
+
if task_num < 2
|
113
|
+
task_num = 2
|
114
|
+
end
|
113
115
|
|
116
|
+
if task_num > 100
|
117
|
+
task_num = 100
|
118
|
+
end
|
119
|
+
|
120
|
+
puts "最大线程数: #{task_num}"
|
121
|
+
puts
|
114
122
|
|
115
123
|
Funlog.instance.fancyinfo_start("开始上传...")
|
116
124
|
@upload_eTags = []
|
@@ -121,6 +129,7 @@ module Pindo
|
|
121
129
|
multi_task_upload_data_req(task_num:task_num)
|
122
130
|
|
123
131
|
result_data = post_upload_finish_req(upload_path_key:upload_path_key, upload_id:upload_id, eTags:@upload_eTags)
|
132
|
+
|
124
133
|
if result_data["code"] == 200
|
125
134
|
upload_result = upload_path_key
|
126
135
|
Funlog.instance.fancyinfo_success("文件#{@upload_binary_file} 上传成功! 😎😎😎")
|
@@ -136,7 +145,6 @@ module Pindo
|
|
136
145
|
|
137
146
|
def multi_task_upload_data_req(task_num:1)
|
138
147
|
|
139
|
-
# puts "add task_num :#{task_num}"
|
140
148
|
|
141
149
|
for i in 0..@upload_params_list.length-1 do
|
142
150
|
@upload_params_list[i]["retryCount"] = 3
|
@@ -145,10 +153,9 @@ module Pindo
|
|
145
153
|
while @upload_params_list.size > 0
|
146
154
|
upload_params_list_temp = []
|
147
155
|
#每次最大5个线程上传
|
148
|
-
for i in
|
156
|
+
for i in 1..task_num do
|
149
157
|
upload_params_list_temp << @upload_params_list.shift
|
150
158
|
end
|
151
|
-
|
152
159
|
hydra = Typhoeus::Hydra.new
|
153
160
|
while upload_params_list_temp.size > 0
|
154
161
|
upload_params_item = upload_params_list_temp.shift
|
@@ -172,11 +179,6 @@ module Pindo
|
|
172
179
|
single_task_upload_part_data_req(upload_params_item:upload_params_item)
|
173
180
|
end
|
174
181
|
|
175
|
-
# if !@upload_params_list.nil? && @upload_params_list.length > 0
|
176
|
-
# for i in 0..@upload_params_list.length-1 do
|
177
|
-
# eTag_item = single_task_upload_part_data_req(upload_params_item:@upload_params_list[i])
|
178
|
-
# end
|
179
|
-
# end
|
180
182
|
|
181
183
|
return @eTags
|
182
184
|
end
|
@@ -200,13 +202,8 @@ module Pindo
|
|
200
202
|
|
201
203
|
request = create_req(upload_url:upload_url, body_data:put_data, read_length:read_length)
|
202
204
|
|
203
|
-
# @upload_num = start_position
|
204
|
-
|
205
205
|
request.on_progress do |dltotal, dlnow, ultotal, ulnow|
|
206
|
-
# puts "dltotal (#{dltotal}), dlnow (#{dlnow}), ultotal (#{ultotal}), ulnow (#{ulnow})"
|
207
206
|
if ulnow
|
208
|
-
# @upload_num = start_position + ulnow
|
209
|
-
# set_progress(@upload_num, @file_size)
|
210
207
|
@progress_bar.update_upload_index(upload_part:part_no, upload_size:ulnow)
|
211
208
|
@progress_bar.update_upload_progress()
|
212
209
|
end
|
@@ -214,17 +211,6 @@ module Pindo
|
|
214
211
|
|
215
212
|
eTag_item = nil
|
216
213
|
|
217
|
-
request.on_failure do |response|
|
218
|
-
@progress_bar.delete_upload_index(upload_part:part_no)
|
219
|
-
upload_params_item["retryCount"] = upload_params_item["retryCount"] - 1
|
220
|
-
if upload_params_item["retryCount"] > 0
|
221
|
-
@upload_params_list.push(upload_params_item)
|
222
|
-
else
|
223
|
-
Funlog.instance.fancyinfo_error("文件#{@upload_binary_file} 上传失败! 😭😭😭")
|
224
|
-
raise Informative "上传文件失败"
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
214
|
request.on_complete do |response|
|
229
215
|
if response.success?
|
230
216
|
@progress_bar.complete_upload_index(upload_part:part_no, complete_size:read_length)
|
@@ -238,7 +224,7 @@ module Pindo
|
|
238
224
|
@upload_params_list.push(upload_params_item)
|
239
225
|
else
|
240
226
|
Funlog.instance.fancyinfo_error("文件#{@upload_binary_file} 上传失败! 😭😭😭")
|
241
|
-
raise Informative "上传文件失败"
|
227
|
+
raise Informative, "上传文件失败"
|
242
228
|
end
|
243
229
|
end
|
244
230
|
end
|
@@ -256,7 +242,6 @@ module Pindo
|
|
256
242
|
def create_req(upload_url:nil, body_data:nil, read_length:nil)
|
257
243
|
|
258
244
|
request = nil
|
259
|
-
|
260
245
|
proxy_options = {
|
261
246
|
proxy: ENV['http_proxy'] || ENV['https_proxy'],
|
262
247
|
proxyuserpwd: "#{ENV['HTTP_PROXY_USER']}:#{ENV['HTTP_PROXY_PASSWORD']}"
|
data/lib/pindo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pindo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|