|
@@ -716,7 +716,7 @@ class DevicePushService:
|
|
|
if storage_reg in [3, 4]:
|
|
|
image_url = DevicePushService.oci_object_url(storage_reg, bucket, key)
|
|
|
elif storage_reg == 5:
|
|
|
- image_url = DevicePushService.create_obs_signed_url(uid, channel, n_time, 'GET')
|
|
|
+ image_url = DevicePushService.create_obs_signed_url(key, 'GET')
|
|
|
else:
|
|
|
image_url = aws_s3_client.generate_presigned_url(
|
|
|
'get_object', Params={'Bucket': bucket, 'Key': key}, ExpiresIn=3600)
|
|
@@ -791,8 +791,7 @@ class DevicePushService:
|
|
|
res_data['msg'] = 'success 1'
|
|
|
else:
|
|
|
# 华为云
|
|
|
- img_url = DevicePushService.create_obs_signed_url(
|
|
|
- params['uid'], params['channel'], params['n_time'], 'PUT')
|
|
|
+ img_url = DevicePushService.create_obs_signed_url(key_name, 'PUT')
|
|
|
res_data['msg'] = 'success 1'
|
|
|
elif is_st == 3:
|
|
|
img_url_list = []
|
|
@@ -813,8 +812,7 @@ class DevicePushService:
|
|
|
img_url_list.append(img_url)
|
|
|
else:
|
|
|
# 华为云
|
|
|
- img_url = DevicePushService.create_obs_signed_url(
|
|
|
- params['uid'], params['channel'], params['n_time'], 'PUT')
|
|
|
+ img_url = DevicePushService.create_obs_signed_url(key_name, 'PUT')
|
|
|
res_data['img_url_list'] = img_url_list
|
|
|
res_data['msg'] = 'success 3'
|
|
|
return res_data
|
|
@@ -832,15 +830,17 @@ class DevicePushService:
|
|
|
return response_url
|
|
|
|
|
|
@staticmethod
|
|
|
- def create_obs_signed_url(uid, channel, n_time, method):
|
|
|
+ def create_obs_signed_url(key_name, method):
|
|
|
"""
|
|
|
生成对象存储预签名URL
|
|
|
+ @param key_name: 对象名称
|
|
|
+ @param method: 方法
|
|
|
+ @return: 预签名URL
|
|
|
"""
|
|
|
- object_key = '{}/{}/{}.jpeg'.format(uid, channel, n_time)
|
|
|
obs_client = ObsClient(
|
|
|
access_key_id=HUAWEICLOUD_AK, secret_access_key=HUAWEICLOUD_SK, server=HUAWEICLOUD_OBS_SERVER)
|
|
|
res = obs_client.createSignedUrl(
|
|
|
- method=method, bucketName=HUAWEICLOUD_PUSH_BUKET, objectKey=object_key, expires=3600)
|
|
|
+ method=method, bucketName=HUAWEICLOUD_PUSH_BUKET, objectKey=key_name, expires=3600)
|
|
|
return res.signedUrl
|
|
|
|
|
|
@staticmethod
|