Skip to content

Commit f04c995

Browse files
authored
resume upload part concurrently (#440)
1 parent 7d6eb2d commit f04c995

17 files changed

+2710
-444
lines changed

Diff for: .github/workflows/ci-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
shell: bash -l {0}
4040
run: |
4141
python -m pip install --upgrade pip
42-
python -m pip install --ignore-installed "coverage<7.2" flake8 pytest pytest-cov freezegun requests scrutinizer-ocular codecov
42+
python -m pip install -I -e ".[dev]"
4343
- name: Run cases
4444
shell: bash -l {0}
4545
env:

Diff for: qiniu/auth.py

+8
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def upload_token(
144144
key: 上传的文件名,默认为空
145145
expires: 上传凭证的过期时间,默认为3600s
146146
policy: 上传策略,默认为空
147+
strict_policy: 严格模式,将校验 policy 字段,默认为 True
147148
148149
Returns:
149150
上传凭证
@@ -175,6 +176,13 @@ def up_token_decode(up_token):
175176
dict_policy = json.loads(decode_policy)
176177
return ak, sign, dict_policy
177178

179+
@staticmethod
180+
def get_bucket_name(up_token):
181+
_, _, policy = Auth.up_token_decode(up_token)
182+
if not policy or not policy['scope']:
183+
return None
184+
return policy['scope'].split(':', 1)[0]
185+
178186
def __upload_token(self, policy):
179187
data = json.dumps(policy, separators=(',', ':'))
180188
return self.token_with_data(data)

Diff for: qiniu/compat.py

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
pythoncompat
55
"""
66

7+
import os
78
import sys
89

910
try:
@@ -51,6 +52,13 @@ def s(data):
5152
def u(data):
5253
return unicode(data, 'unicode_escape') # noqa
5354

55+
def is_seekable(data):
56+
try:
57+
data.seek(0, os.SEEK_CUR)
58+
return True
59+
except (AttributeError, IOError):
60+
return False
61+
5462
elif is_py3:
5563
from urllib.parse import urlparse # noqa
5664
import io
@@ -75,3 +83,6 @@ def s(data):
7583

7684
def u(data):
7785
return data
86+
87+
def is_seekable(data):
88+
return data.seekable()

Diff for: qiniu/region.py

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def get_api_host(self, ak, bucket, home_dir=None):
110110
return api_hosts[0]
111111

112112
def get_up_host(self, ak, bucket, home_dir):
113+
if home_dir is None:
114+
home_dir = os.getcwd()
113115
bucket_hosts = self.get_bucket_hosts(ak, bucket, home_dir)
114116
if 'upHosts' not in bucket_hosts:
115117
bucket_hosts = self.get_bucket_hosts(ak, bucket, home_dir, force=True)

0 commit comments

Comments
 (0)