统一引号格式,优化架构排布
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
from ufile import config
|
||||
|
||||
# 公钥
|
||||
PUBLIC_KEY = "4Z7QYI7qml36QRjcCjKrls7aHl1R6H6uq"
|
||||
PUBLIC_KEY = '4Z7QYI7qml36QRjcCjKrls7aHl1R6H6uq'
|
||||
# 私钥
|
||||
PRIVATE_KEY = "FIdW1Kev1Ge3K7GHXzSLyGG1wTnaG6LE9BxmIVubcCaG"
|
||||
PRIVATE_KEY = 'FIdW1Kev1Ge3K7GHXzSLyGG1wTnaG6LE9BxmIVubcCaG'
|
||||
# 桶
|
||||
BUCKET = "drg100"
|
||||
BUCKET = 'drg100'
|
||||
# 上传后缀
|
||||
UPLOAD_SUFFIX = ".cn-sh2.ufileos.com"
|
||||
UPLOAD_SUFFIX = '.cn-sh2.ufileos.com'
|
||||
# 下载后缀
|
||||
DOWNLOAD_SUFFIX = ".cn-sh2.ufileos.com"
|
||||
DOWNLOAD_SUFFIX = '.cn-sh2.ufileos.com'
|
||||
# 私空间文件地址过期时间(秒)
|
||||
PRIVATE_EXPIRES = 3600
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ def get_private_url(key, bucket=BUCKET):
|
||||
# 判断文件是否存在
|
||||
_, resp = UFILE_HANDLER.head_file(bucket, key)
|
||||
if resp.status_code == -1:
|
||||
UCLOUD_LOGGER.warning(f"查询({key})时uCloud连接失败!")
|
||||
raise ConnectionError("uCloud连接失败")
|
||||
UCLOUD_LOGGER.warning(f'查询({key})时uCloud连接失败!')
|
||||
raise ConnectionError('uCloud连接失败')
|
||||
if resp.status_code != 200:
|
||||
UCLOUD_LOGGER.warning(f"[{bucket}]中未找到({key})! status: {resp.status_code} error: {resp.error}")
|
||||
UCLOUD_LOGGER.warning(f'[{bucket}]中未找到({key})! status: {resp.status_code} error: {resp.error}')
|
||||
return None
|
||||
|
||||
# 获取公有空间下载url
|
||||
@@ -37,11 +37,11 @@ def copy_file(source_bucket, source_key, target_bucket, target_key):
|
||||
# 复制文件
|
||||
_, resp = UFILE_HANDLER.copy(target_bucket, target_key, source_bucket, source_key)
|
||||
if resp.status_code == -1:
|
||||
UCLOUD_LOGGER.warning(f"复制({source_key})时uCloud连接失败!")
|
||||
UCLOUD_LOGGER.warning(f'复制({source_key})时uCloud连接失败!')
|
||||
return False
|
||||
if resp.status_code != 200:
|
||||
UCLOUD_LOGGER.warning(
|
||||
f"将({source_key})从[{source_bucket}]拷贝到[{target_bucket}]失败! status: {resp.status_code} error: {resp.error}"
|
||||
f'将({source_key})从[{source_bucket}]拷贝到[{target_bucket}]失败! status: {resp.status_code} error: {resp.error}'
|
||||
)
|
||||
return False
|
||||
return True
|
||||
@@ -53,9 +53,9 @@ def upload_file(key, file_path, bucket=BUCKET):
|
||||
# 普通上传文件至云空间
|
||||
_, resp = UFILE_HANDLER.putfile(bucket, key, file_path, header=None)
|
||||
if resp.status_code == -1:
|
||||
UCLOUD_LOGGER.warning(f"上传({key})时uCloud连接失败!")
|
||||
UCLOUD_LOGGER.warning(f'上传({key})时uCloud连接失败!')
|
||||
return False
|
||||
if resp.status_code != 200:
|
||||
UCLOUD_LOGGER.warning(f"上传({key})失败! status: {resp.status_code} error: {resp.error}")
|
||||
UCLOUD_LOGGER.warning(f'上传({key})失败! status: {resp.status_code} error: {resp.error}')
|
||||
return False
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user