|
@@ -1,3 +1,4 @@
|
|
|
+import datetime
|
|
|
import json
|
|
|
import time
|
|
|
|
|
@@ -13,6 +14,7 @@ from Ansjer.config import DETECT_PUSH_DOMAIN, DETECT_PUSH_DOMAINS, DETECT_PUSH_D
|
|
|
from Model.models import Device_Info, Equipment_Info, UidSetModel, UidPushModel, CompanyModel, SysMsgModel, \
|
|
|
AiService, VodBucketModel
|
|
|
from Object.ETkObject import ETkObject
|
|
|
+from Object.OCIObjectStorage import OCIObjectStorage
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -20,6 +22,7 @@ from Object.utils import LocalDateTimeUtil
|
|
|
from Service.CommonService import CommonService
|
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
|
+from Ansjer.config import PUSH_BUCKET
|
|
|
|
|
|
|
|
|
class DetectControllerViewV2(View):
|
|
@@ -384,6 +387,8 @@ class DetectControllerViewV2(View):
|
|
|
thumbspng = '{}/{}/{}.jpeg'.format(uid, channel, event_time)
|
|
|
if storage_location == 1: # 阿里云oss
|
|
|
img_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ elif storage_location in [3, 4]:
|
|
|
+ img_url = DetectControllerViewV2.oci_object_url(storage_location, thumbspng)
|
|
|
else:
|
|
|
params = {'Key': thumbspng}
|
|
|
if region == 1: # AWS国外
|
|
@@ -439,6 +444,8 @@ class DetectControllerViewV2(View):
|
|
|
thumbspng = '{}/{}/{}_{}.jpeg'.format(uid, channel, event_time, i)
|
|
|
if storage_location == 1: # 阿里云oss
|
|
|
img_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ elif storage_location in [3, 4]:
|
|
|
+ img_url = DetectControllerViewV2.oci_object_url(storage_location, thumbspng)
|
|
|
else:
|
|
|
params = {'Key': thumbspng}
|
|
|
if region == 1: # 国外AWS
|
|
@@ -470,6 +477,19 @@ class DetectControllerViewV2(View):
|
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def oci_object_url(storage_location, obj_name):
|
|
|
+ """
|
|
|
+ 获取OCI对象存储URL 有效期5分钟
|
|
|
+ @param storage_location: 存储区域
|
|
|
+ @param obj_name: 对象名称
|
|
|
+ @return: url
|
|
|
+ """
|
|
|
+ oci = OCIObjectStorage('eur' if storage_location == 4 else 'us')
|
|
|
+ time_expires = datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
|
|
|
+ result = oci.get_preauthenticated_request_url(PUSH_BUCKET, 'ociPush', obj_name, time_expires)
|
|
|
+ return result.full_path if result else ''
|
|
|
+
|
|
|
def do_transfer(self, request_dict, response, userID):
|
|
|
event_time = request_dict.get('eventTime', None)
|
|
|
event_type = request_dict.get('eventType', None)
|
|
@@ -526,6 +546,8 @@ class DetectControllerViewV2(View):
|
|
|
thumbspng = '{}/{}/{}.jpeg'.format(uid, channel, event_time)
|
|
|
if storage_location == 1: # 阿里云oss
|
|
|
img_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ elif storage_location in [3, 4]:
|
|
|
+ img_url = DetectControllerViewV2.oci_object_url(storage_location, thumbspng)
|
|
|
else:
|
|
|
params = {'Key': thumbspng}
|
|
|
if region == 1: # AWS国外
|
|
@@ -581,6 +603,8 @@ class DetectControllerViewV2(View):
|
|
|
thumbspng = '{}/{}/{}_{}.jpeg'.format(uid, channel, event_time, i)
|
|
|
if storage_location == 1: # 阿里云oss
|
|
|
img_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ elif storage_location in [3, 4]:
|
|
|
+ img_url = DetectControllerViewV2.oci_object_url(storage_location, thumbspng)
|
|
|
else:
|
|
|
params = {'Key': thumbspng}
|
|
|
if region == 1: # 国外AWS
|