Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion publish_scripts/PypiIndexUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
from baidubce.services.bos.bos_client import BosClient


def _get_put_super_object_from_file(bos_client):
"""Return the multipart upload method supported by the installed BCE SDK."""
if hasattr(bos_client, "put_super_object_from_file"):
return bos_client.put_super_object_from_file
return bos_client.put_super_obejct_from_file


def VersionVerification():
"""
Expand Down Expand Up @@ -94,7 +100,7 @@ def upload2bos(bucket_name, file_name):
linux_path = path.as_posix()
object_key = linux_path

result = bos_client.put_super_obejct_from_file(
result = _get_put_super_object_from_file(bos_client)(
bucket_name, object_key, file_name, chunk_size=100, thread_num=multiprocessing.cpu_count()
)
if result:
Expand Down
11 changes: 10 additions & 1 deletion tools/bos_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@
config = BceClientConfiguration(credentials=BceCredentials(access_key_id, secret_access_key), endpoint=bos_host)
bos_client = BosClient(config)


def _get_put_super_object_from_file(bos_client):
"""Return the multipart upload method supported by the installed BCE SDK."""
if hasattr(bos_client, "put_super_object_from_file"):
return bos_client.put_super_object_from_file
return bos_client.put_super_obejct_from_file


def bos_upload(bucket_name, object_key, file_name):
result = bos_client.put_super_obejct_from_file(
result = _get_put_super_object_from_file(bos_client)(
bucket_name, object_key, file_name, chunk_size=100, thread_num=multiprocessing.cpu_count()
)
if result:
print("Upload success!")


def bos_download_url(bucket_name, object_key):
# 建议使用0.9.29版本的bce-python-sdk
print("Please ensure you are using bce-python-sdk version 0.9.29 or later.")
Expand Down
9 changes: 8 additions & 1 deletion tools/bos_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
from baidubce.services.bos.bos_client import BosClient


def _get_put_super_object_from_file(bos_client):
"""Return the multipart upload method supported by the installed BCE SDK."""
if hasattr(bos_client, "put_super_object_from_file"):
return bos_client.put_super_object_from_file
return bos_client.put_super_obejct_from_file


# 设置BosClient的Host,Access Key ID和Secret Access Key
bos_host = "bj.bcebos.com"
access_key_id = os.getenv("AK")
Expand All @@ -37,7 +44,7 @@
else:
chunk_size = 100

result = bos_client.put_super_obejct_from_file(
result = _get_put_super_object_from_file(bos_client)(
bucket_name, object_key, file_name, chunk_size=100, thread_num=multiprocessing.cpu_count()
)
if result:
Expand Down