|
|
|
@ -31,8 +31,8 @@ class DownloadView(APIView): |
|
|
|
|
|
|
|
|
|
def get(self, request, filename): |
|
|
|
|
res = BaseResponse() |
|
|
|
|
downtoken = request.query_params.get("token", None) |
|
|
|
|
ftype = request.query_params.get("ftype", None) |
|
|
|
|
downtoken = request.query_params.get(settings.DATA_DOWNLOAD_KEY, None) |
|
|
|
|
ftype = filename.split(".")[-1] |
|
|
|
|
if not downtoken: |
|
|
|
|
res.code = 1004 |
|
|
|
|
res.msg = "缺失token" |
|
|
|
@ -40,17 +40,6 @@ class DownloadView(APIView): |
|
|
|
|
|
|
|
|
|
dtoken = DownloadToken() |
|
|
|
|
if dtoken.verify_token(downtoken, filename): |
|
|
|
|
if not ftype: |
|
|
|
|
file_path = os.path.join(settings.MEDIA_ROOT, filename) |
|
|
|
|
try: |
|
|
|
|
response = FileResponse(open(file_path, 'rb')) |
|
|
|
|
except Exception as e: |
|
|
|
|
print(e) |
|
|
|
|
response = FileResponse() |
|
|
|
|
response['content_type'] = "application/octet-stream" |
|
|
|
|
response['Content-Disposition'] = 'attachment; filename=' + filename |
|
|
|
|
return response |
|
|
|
|
else: |
|
|
|
|
if ftype == 'plist': |
|
|
|
|
release_id = filename.split('.')[0] |
|
|
|
|
apptodev_obj = APPToDeveloper.objects.filter(binary_file=release_id).first() |
|
|
|
@ -63,7 +52,7 @@ class DownloadView(APIView): |
|
|
|
|
bundle_id = release_obj.app_id.bundle_id |
|
|
|
|
app_version = release_obj.app_version |
|
|
|
|
name = release_obj.app_id.name |
|
|
|
|
ios_plist_bytes = make_resigned(storage.get_download_url(filename), |
|
|
|
|
ios_plist_bytes = make_resigned(storage.get_download_url(filename.split('.')[0]+".ipa"), |
|
|
|
|
storage.get_download_url(release_obj.icon_url), bundle_id, |
|
|
|
|
app_version, name) |
|
|
|
|
response = FileResponse(ios_plist_bytes) |
|
|
|
@ -82,6 +71,16 @@ class DownloadView(APIView): |
|
|
|
|
response['Content-Disposition'] = 'attachment; filename=' + make_random_uuid() + '.mobileconfig' |
|
|
|
|
return response |
|
|
|
|
res.msg = "mobileconifg release_id error" |
|
|
|
|
else: |
|
|
|
|
file_path = os.path.join(settings.MEDIA_ROOT, filename) |
|
|
|
|
try: |
|
|
|
|
response = FileResponse(open(file_path, 'rb')) |
|
|
|
|
except Exception as e: |
|
|
|
|
print(e) |
|
|
|
|
response = FileResponse() |
|
|
|
|
response['content_type'] = "application/octet-stream" |
|
|
|
|
response['Content-Disposition'] = 'attachment; filename=' + filename |
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
res.code = 1004 |
|
|
|
|
res.msg = "token校验失败" |
|
|
|
@ -166,7 +165,7 @@ class InstallView(APIView): |
|
|
|
|
udid=udid) |
|
|
|
|
|
|
|
|
|
res.data = {"download_url": download_url} |
|
|
|
|
if download_url != "" and not download_url.endswith("mobileconifg"): |
|
|
|
|
if download_url != "" and "mobileconifg" not in download_url: |
|
|
|
|
set_app_download_by_cache(app_id) |
|
|
|
|
return Response(res.dict) |
|
|
|
|
else: |
|
|
|
|