Let me start by saying I have spent a lot of energy on this and any input is very valuable to me at this point. Now, onto my question:
What I have working: My website provides a simple interface for users to upload a file in which they will be given a key. The file is saved to the server and the key is generated using a modern, secure encryption algorithm. These details are not important to the question at hand.
What I want to implement: On a download page, the user can enter the key and the file will be downloaded to their computer. Want I want to know is how to provide a user with this ability to download an uploaded file. To put it simply, I just want to allow users to download a file in the MEDIA_ROOT folder.
I am using class-based views, so my urls are:
urls.py
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.conf import settings
from fileupload.views import FileDownloadView, GetFileView
urlpatterns = patterns('',
url(r'^key/?$', FileDownloadView.as_view(), name='getkey'),
url(r'^download/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}, GetFileView.as_view()),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Please provide me with the basic idea on what functions I should use in my views to actually download the file. I am still in development so I want to take advantage of Django's ability to serve files, not Apache's. I will consider other options if I go into production. Whatever code I need to post, I can post.
Thank you!