newmediamonitoring/polls/views/download.py

12 lines
494 B
Python
Raw Normal View History

2020-10-11 08:58:55 +00:00
import os
from django.conf import settings
from django.http import HttpResponse, Http404
def download(request):
file_path = os.path.join(settings.MEDIA_ROOT, 'pom.apk')
if os.path.exists(file_path):
with open(file_path, 'rb') as fh:
response = HttpResponse(fh.read(), content_type="application/vnd.android.package-archive")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404