|
@@ -18,6 +18,20 @@ from Ansjer.config import BASE_DIR
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
import os
|
|
import os
|
|
|
|
+import time
|
|
|
|
+import traceback
|
|
|
|
+import os
|
|
|
|
+from django.shortcuts import render_to_response
|
|
|
|
+from django.utils.decorators import method_decorator
|
|
|
|
+from django.views.decorators.csrf import csrf_exempt
|
|
|
|
+from django.views.generic.base import View
|
|
|
|
+
|
|
|
|
+from Model.models import App_Info, App_Colophon
|
|
|
|
+from Object.ResponseObject import ResponseObject
|
|
|
|
+from Object.TokenObject import TokenObject
|
|
|
|
+from Service.CommonService import CommonService
|
|
|
|
+from Service.ModelService import ModelService
|
|
|
|
+from Ansjer.config import BASE_DIR, SERVER_DOMAIN
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
@csrf_exempt
|
|
@@ -30,10 +44,10 @@ def updateLog(request):
|
|
request_dict = request.POST
|
|
request_dict = request.POST
|
|
else:
|
|
else:
|
|
response.json(404)
|
|
response.json(404)
|
|
- token = request_dict.get('token',None)
|
|
|
|
- content = request_dict.get('content',None)
|
|
|
|
|
|
+ token = request_dict.get('token', None)
|
|
|
|
+ content = request_dict.get('content', None)
|
|
if not content:
|
|
if not content:
|
|
- return response.json(444,'content')
|
|
|
|
|
|
+ return response.json(444, 'content')
|
|
tko = TokenObject(token)
|
|
tko = TokenObject(token)
|
|
response.lang = tko.lang
|
|
response.lang = tko.lang
|
|
if tko.code != 0:
|
|
if tko.code != 0:
|
|
@@ -51,28 +65,43 @@ def updateLog(request):
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
|
|
|
|
-# 文件流下载
|
|
|
|
-@csrf_exempt
|
|
|
|
-def downloadOTAInterface(request, fullPath, *callback_args, **callback_kwargs):
|
|
|
|
- res = ResponseObject()
|
|
|
|
- print('fullPath:')
|
|
|
|
- print(fullPath)
|
|
|
|
- if fullPath:
|
|
|
|
|
|
+class getStatView(View):
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
+ request.encoding = 'utf-8'
|
|
|
|
+ filePath = kwargs.get('filePath', None)
|
|
|
|
+ filePath.encode(encoding='utf-8', errors='strict')
|
|
|
|
+ response = ResponseObject()
|
|
|
|
+ return self.getFile(filePath, response)
|
|
|
|
+
|
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
|
+ request.encoding = 'gb2312'
|
|
|
|
+ filePath = kwargs.get('filePath', None)
|
|
|
|
+ response = ResponseObject()
|
|
|
|
+ filePath.encode(encoding='gb2312', errors='strict')
|
|
|
|
+ return self.getFile(filePath, response)
|
|
|
|
+
|
|
|
|
+ def getFile(self, filePath,response):
|
|
|
|
+ if filePath:
|
|
|
|
+ pass
|
|
|
|
+ else:
|
|
|
|
+ return response.json(800)
|
|
|
|
+ fullPath = os.path.join(BASE_DIR, "static", filePath).replace('\\', '/')
|
|
|
|
+ defaultPath = os.path.join(BASE_DIR, "static", "User/default.png").replace('\\', '/')
|
|
if os.path.isfile(fullPath):
|
|
if os.path.isfile(fullPath):
|
|
try:
|
|
try:
|
|
- wrapper = FileWrapper(open(fullPath, 'rb'))
|
|
|
|
- response = HttpResponse(wrapper, content_type="application/octet-stream")
|
|
|
|
- response['Content-Length'] = os.path.getsize(fullPath)
|
|
|
|
- response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(fullPath)
|
|
|
|
- response['Content-MD5'] = getMD5orSHA265(fullPath)
|
|
|
|
- # 校验文件md5值
|
|
|
|
- response['Content-SHA265'] = getMD5orSHA265(fullPath, 'SHA265')
|
|
|
|
- response['Content-CRC32'] = getMD5orSHA265(fullPath, 'CRC32')
|
|
|
|
- response['Content-Error'] = res.formal(0)
|
|
|
|
- return response
|
|
|
|
|
|
+ Imagedata = open(fullPath, 'rb').read()
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- return res.json(906, repr(e))
|
|
|
|
|
|
+ return response.json(906, repr(e))
|
|
|
|
+ else:
|
|
|
|
+ return HttpResponse(Imagedata, content_type="image/jpeg")
|
|
else:
|
|
else:
|
|
- return res.json(907)
|
|
|
|
- else:
|
|
|
|
- return res.json(444, 'fullPath')
|
|
|
|
|
|
+ print('----------------')
|
|
|
|
+ print(defaultPath)
|
|
|
|
+ print('----------------')
|
|
|
|
+ try:
|
|
|
|
+ Imagedata = open(defaultPath, 'rb').read()
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return response.json(906, repr(e))
|
|
|
|
+ else:
|
|
|
|
+ return HttpResponse(Imagedata, content_type="image/jpeg")
|
|
|
|
+ # return response.json(907)
|