You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.9 KiB
70 lines
2.9 KiB
1 month ago
|
# 引入模块
|
||
|
import os
|
||
|
import tos
|
||
|
|
||
|
#https://panduola-cdn-xcx-dev.yingxiong.com/2h/StreamingAssets/main/pm_main_1.0.1.bytes pm_main.version
|
||
|
#https://panduola-cdn-xcx-dev.yingxiong.com/2h/AssetLoadPath.txt
|
||
|
#'DATA_CDN/assets_scenes_build_8ad4b0cce7371c3a4a9b61fdaa4334b7.ab'
|
||
|
|
||
|
ak = "AKLTOTY0N2JmMDczZTdhNDNlZWE5Y2QyMTVkZmM5ZjU1ZDA"
|
||
|
sk = "TjJFNE5qZ3hNR0ZqWlRJME5EUXpZMkk0T1dRelpHSmlaREptWXpJeU56UQ=="
|
||
|
endpoint = "tos-cn-beijing.volces.com"
|
||
|
region = "cn-beijing"
|
||
|
bucket_name = "huoliqiang"
|
||
|
current_directory = os.getcwd().replace("\\", "/")
|
||
|
client = tos.TosClientV2(ak, sk, endpoint, region)
|
||
|
|
||
|
def upload_file(bucketName, objectKey, file_path):
|
||
|
try:
|
||
|
print('\'{}\','.format(file_path))
|
||
|
client.put_object_from_file(bucketName, objectKey, file_path)
|
||
|
except tos.exceptions.TosClientError as e:
|
||
|
# Operation failed, catch client error, usually caused by invalid request parameters or network issues
|
||
|
print('fail with client error, message:{}, cause: {}'.format(e.message, e.cause))
|
||
|
except tos.exceptions.TosServerError as e:
|
||
|
# Operation failed, catch server error, detailed error information can be obtained from the response
|
||
|
print('fail with server error, code: {}'.format(e.code))
|
||
|
# request id can be used to locate specific issues, it is strongly recommended to save it in the log.
|
||
|
print('error with request id: {}'.format(e.request_id))
|
||
|
print('error with message: {}'.format(e.message))
|
||
|
print('error with http code: {}'.format(e.status_code))
|
||
|
print('error with ec: {}'.format(e.ec))
|
||
|
print('error with request url: {}'.format(e.request_url))
|
||
|
except Exception as e:
|
||
|
print('fail with unknown error: {}'.format(e))
|
||
|
|
||
|
def list_files(startpath, mdict):
|
||
|
for root, dirs, files in os.walk(startpath):
|
||
|
if 'OutputCache' in dirs:
|
||
|
dirs.remove('OutputCache')
|
||
|
if 'Simulate' in dirs:
|
||
|
dirs.remove('Simulate')
|
||
|
level = root.replace(startpath, '').count(os.sep)
|
||
|
indent = ' ' * 4 * (level)
|
||
|
print('{}/'.format(os.path.join(startpath, root)))
|
||
|
subindent = ' ' * 4 * (level + 1)
|
||
|
for f in files:
|
||
|
if ".bytes" in f:
|
||
|
upload_file(bucket_name, '2h2/StreamingAssets/main/{}'.format(f), os.path.join(root, f))
|
||
|
if "version" in f:
|
||
|
upload_file(bucket_name, '2h2/StreamingAssets/main/{}'.format(f), os.path.join(root, f))
|
||
|
|
||
|
if mdict.get(f):
|
||
|
continue
|
||
|
upload_file(bucket_name, '2h2/{}'.format(f), os.path.join(root, f))
|
||
|
|
||
|
|
||
|
folder = 'D:/2h/client/client/Bundles/WebGL/main/1.0.4x' #差量上传的base
|
||
|
filelist=[]
|
||
|
if os.path.exists(folder):
|
||
|
filelist = os.listdir(folder)
|
||
|
|
||
|
my_dict = {item: index for index, item in enumerate(filelist, start=1)}
|
||
|
folder = 'D:/2h/client/client/Bundles/WebGL/main/1.0.44'
|
||
|
list_files(folder, my_dict)
|
||
|
|
||
|
# https://panduola-cdn-xcx-dev.yingxiong.com/
|
||
|
# upload_file("panduola-dev", )placeholder
|
||
|
# 关闭obsClient
|
||
|
client.close()
|