Wednesday, November 28, 2012

Re: Where to put PDF files + how to authenticate the urls requesting them

On Wed, Nov 28, 2012 at 5:51 AM, Loai Ghoraba <loai1991@gmail.com> wrote:
> Hi
>
> I have a little question: First, I am hosting my PDF files within /
> static directory, (as my understanding is that they are static files),
> so is this the correct way to host PDF files and downloadable files
> generally ?
>
> Second: Only authenticated users may view the links for those PDF
> files, but what if someone knows the url of the files ? he can just
> get them. So how to authenticate a url call to a static file ?


I asked mostly the same thing in StackOverflow a few years ago:

http://stackoverflow.com/questions/263122/custom-http-headers-for-static-files-with-django

The idea is to handle the request with Django, then you can validate
permissions, set headers (for the download name, for example) but
instead of serving the data, you add an extra header
(x-accell-redirect for nginx) that tells the server to add a file
content.

i think there are a couple Django apps that help with that, while also
abstracting the differences between servers.

--
Javier

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment