I am using django to design the basic web pages that handles the uploading and downloading of the files to/from the media folder
import urllib, mimetypes
from django.http import HttpResponse, Http404, StreamingHttpResponse, FileResponse
import os
from django.conf import settings
from wsgiref.util import FileWrapper
class DownloadFileView(django_views):
def get(self,request,file_name):
file_path = settings.MEDIA_ROOT +'/'+ file_name
file_wrapper = FileWrapper(open(file_path,'rb'))
file_mimetype = mimetypes.guess_type(file_path)
response = HttpResponse(file_wrapper, content_type=file_mimetype )
response['X-Sendfile'] = file_path
response['Content-Length'] = os.stat(file_path).st_size
response['Content-Disposition'] = 'attachment; filename=%s/' % str(file_name)
return response