chenjunkai %!s(int64=6) %!d(string=hai) anos
pai
achega
776d3f0cd0
Modificáronse 3 ficheiros con 8 adicións e 6 borrados
  1. 1 1
      Ansjer/config.py
  2. 6 5
      Controller/CloudVod.py
  3. 1 0
      Model/models.py

+ 1 - 1
Ansjer/config.py

@@ -68,7 +68,7 @@ elif SERVER_TYPE == 'Ansjer.formal_settings':
 
 # oss param
 OSS_BUCKET_VOD_LIST = {1: 'cloudvod1', 2: 'cloudvod2', 3: 'cloudvod3'}
-OSS_BUCKET_ENDPOINT = 'oss-cn-shenzhen.aliyuncs.com'
+OSS_BUCKET_ENDPOINT = ''
 OSS_STS_ACCESS_KEY = 'LTAIyMkGfEdogyL9'
 OSS_STS_ACCESS_SECRET = '71uIjpsqVOmF7DAITRyRuc259jHOjO'
 OSS_REGION_ID = 'cn-shenzhen'

+ 6 - 5
Controller/CloudVod.py

@@ -26,7 +26,7 @@ from django.views.decorators.csrf import csrf_exempt
 from django.views.generic.base import View
 import urllib
 
-from Ansjer.config import OSS_BUCKET_ENDPOINT, OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, \
+from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, \
     OSS_REGION_ID, OSS_ROLE_ARN, SERVER_DOMAIN
 from Model.models import Device_Meal, Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel
 from Object.ResponseObject import ResponseObject
@@ -195,7 +195,7 @@ class CloudVodView(View):
         channel = utko.channel
         print(channel)
         print(UID)
-        qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("channel", "end_time","rank__bucket__bucket")
+        qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("channel", "end_time","rank__bucket__bucket","rank__bucket__endpoint")
         if not qs.exists():
             res = {'code': 403}
             return JsonResponse(status=200, data=res)
@@ -217,7 +217,7 @@ class CloudVodView(View):
         # 套餐id
         storage = '{uid}/vod{channel}/'.format(uid=UID, channel=channel)
         bucket_name = qs[0]['rank__bucket__bucket']
-        endpoint = OSS_BUCKET_ENDPOINT
+        endpoint = qs[0]['rank__bucket__endpoint']
         access_key_id = OSS_STS_ACCESS_KEY
         access_key_secret = OSS_STS_ACCESS_SECRET
         region_id = OSS_REGION_ID
@@ -288,15 +288,16 @@ class CloudVodView(View):
         if not qs.exists():
             return response.json(13)
         uid = qs[0]['UID']
-        dm_qs = Device_Meal.objects.filter(uid=uid, channel=channel).values('rank__bucket__bucket','end_time')
+        dm_qs = Device_Meal.objects.filter(uid=uid, channel=channel).values('rank__bucket__bucket','end_time','rank__bucket__endpoint')
         now_time = timezone.localtime(timezone.now())
         if now_time > dm_qs[0]['end_time']:
             return response.json(10, '已过期')
         if not dm_qs.exists():
             return response.json(10, '未开通云存储')
         bucket_name = dm_qs[0]["rank__bucket__bucket"]
+        endpoint = dm_qs[0]["rank__bucket__endpoint"]
         auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
-        bucket = oss2.Bucket(auth, OSS_BUCKET_ENDPOINT, bucket_name)
+        bucket = oss2.Bucket(auth, endpoint, bucket_name)
         vod_play_list = []
         prefix = '{uid}/vod{channel}/{daytime}/'.format(uid=uid, channel=channel, daytime=daytime, hour=hour)
 

+ 1 - 0
Model/models.py

@@ -461,6 +461,7 @@ class VodBucketModel(models.Model):
     storeDay = models.IntegerField(default=0, verbose_name='存储生命周期(天)')
     content = models.TextField(verbose_name='描述')
     endpoint = models.CharField(max_length=125,default='', verbose_name='存储节点')
+    area = models.CharField(max_length=16,default='', verbose_name='区域')
     addTime = models.IntegerField(verbose_name='添加时间', default=0)
     updTime = models.IntegerField(verbose_name='更新时间', default=0)