|
@@ -23,6 +23,7 @@ import json
|
|
|
from alipay import AliPay
|
|
|
import time
|
|
|
import apns2
|
|
|
+from django.http import JsonResponse
|
|
|
|
|
|
|
|
|
# 测试接口sdk
|
|
@@ -31,9 +32,6 @@ class Test(View):
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
|
|
request_dict = request.GET
|
|
|
- op = request_dict.get('op',None)
|
|
|
- if op:
|
|
|
- return self.do_get_aws_kinesis_vidoe()
|
|
|
test_push_type = request_dict.get('test_push_type')
|
|
|
if test_push_type == 'jpush':
|
|
|
return self.jgPush(request)
|
|
@@ -41,9 +39,31 @@ class Test(View):
|
|
|
return self.do_fcm_push(request)
|
|
|
elif test_push_type == 'apns':
|
|
|
return self.do_apns(request.GET)
|
|
|
+ elif test_push_type == 's3sts':
|
|
|
+ return self.do_get_s3_sts()
|
|
|
return self.do_gcm_push(request)
|
|
|
return self.do_alipay_query_status()
|
|
|
|
|
|
+ def do_get_s3_sts(self):
|
|
|
+ import boto3
|
|
|
+ REGION_NAME = 'us-east-1' # e.g
|
|
|
+ import json
|
|
|
+ boto3_sts = boto3.client(
|
|
|
+ 'sts',
|
|
|
+ aws_access_key_id='AKIA2E67UIMD45Y3HL53',
|
|
|
+ aws_secret_access_key='ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw',
|
|
|
+ region_name=REGION_NAME
|
|
|
+ )
|
|
|
+ Policy = {"Version": "2012-10-17", "Statement": [
|
|
|
+ {"Effect": "Allow", "Action": "s3:*", "Resource": ["arn:aws:s3:::azvod1/*"]}]}
|
|
|
+ response = boto3_sts.get_federation_token(
|
|
|
+ Name='chanjunkai@166.com',
|
|
|
+ Policy=json.dumps(Policy),
|
|
|
+ DurationSeconds=7200
|
|
|
+ )
|
|
|
+ return JsonResponse(status=200, data=response)
|
|
|
+
|
|
|
+
|
|
|
def do_get_aws_kinesis_vidoe(self):
|
|
|
import boto3
|
|
|
REGION_NAME = 'us-east-1' # e.g
|