chenjunkai 6 жил өмнө
parent
commit
958b174f52

+ 3 - 0
Ansjer/urls.py

@@ -118,6 +118,9 @@ urlpatterns = [
     url(r'^vodBucket/(?P<operation>.*)$', VodBucket.VodBucketView.as_view()),
     url(r'^UIDBucket/(?P<operation>.*)$', VodBucket.UidBucketView.as_view()),
     url(r'^EquipmentVersion/(?P<operation>.*)$', EquipmentOTA.EquipmentVersionView.as_view()),
+    
+    url(r'^dll/otaPack', OTAEquipment.ddlOTAInterface),
+
     url(r'^deviceShare/(?P<operation>.*)$', DeviceShare.DeviceShareView.as_view()),
     url(r'^appVer/views$', AppInfo.AppVersionView.as_view()),
 

+ 26 - 0
Controller/OTAEquipment.py

@@ -563,4 +563,30 @@ def downloadOTAInterface(request, fullPath, *callback_args, **callback_kwargs):
     else:
         return res.json(444, 'fullPath')
 
+# ota包下载
+@csrf_exempt
+def ddlOTAInterface(request, *callback_args, **callback_kwargs):
+    res = ResponseObject()
+    print('fullPath:')
+    fullPath = 'static/otapack/DVR/en/V1.6.1.21AX1610010480000600000280001A.tar.gz'
+    if fullPath:
+        if os.path.isfile(fullPath):
+            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
+            except Exception as e:
+                return res.json(906, repr(e))
+        else:
+            return res.json(907)
+    else:
+        return res.json(444, 'fullPath')
+