|
@@ -99,8 +99,11 @@ class testView(View):
|
|
|
elif operation == 'generateToken':
|
|
|
userID = '158943604783713800138000'
|
|
|
return self.generate_token(request_dict,userID)
|
|
|
+ elif operation == 'test_upload_s3':
|
|
|
+ userID = '158943604783713800138000'
|
|
|
+ return self.test_upload_s3(request_dict)
|
|
|
else:
|
|
|
- return 12344444
|
|
|
+ return 123
|
|
|
|
|
|
def createBucket(self):
|
|
|
|
|
@@ -686,4 +689,20 @@ class testView(View):
|
|
|
#uidToken
|
|
|
# utko = UidTokenObject()
|
|
|
# res = utko.generate(data={'uid':'86YC8Z192VB1VMKU111A','channel':1})
|
|
|
- return JsonResponse(status=200, data=res,safe=False)
|
|
|
+ return JsonResponse(status=200, data=res,safe=False)
|
|
|
+
|
|
|
+ def test_upload_s3(self,request_dict):
|
|
|
+ aws_key = "ASIA2E67UIMDZLXCH7FM" #【你的 aws_access_key】
|
|
|
+ aws_secret = "1XLBpy+hkUhBmuECaVyNUo6cJQfDGoaMcWLvpcyc" # 【你的 aws_secret_key】
|
|
|
+ session = Session(aws_access_key_id=aws_key,
|
|
|
+ aws_secret_access_key=aws_secret,
|
|
|
+ region_name="uap-southeast-1") # 此处根据自己的 s3 地区位置改变
|
|
|
+ s3 = session.resource("s3")
|
|
|
+ client = session.client("s3")
|
|
|
+ bucket = "asj-oct-ipc" # 【你 bucket 的名字】 # 首先需要保.证 s3 上已经存在该存储桶,否则报错
|
|
|
+ upload_data = open("./././static/log/error.log", "rb")
|
|
|
+ upload_key = "test"
|
|
|
+ file_obj = s3.Bucket(bucket).put_object(Key=upload_key, Body=upload_data)
|
|
|
+ print('--------')
|
|
|
+ print(file_obj)
|
|
|
+ return JsonResponse(status=200, data=file_obj,safe=False)
|