Besides, i've found that www.lawrence.com and www.ljworld.com (which
are famous sites that use django) use a http://media.their-domain-name.com
to store the media files.
All static files, images, css are from the http://media.their-domain-name.com
server. Obviously the media subdomain is not a django environment, i
wonder if we can setup an environment like that, and can i still
upload image to the media subdomain from the django admin console?
Arnold
How to serve static file by "pushing" a PDF to client? In php, there
is a way to serve PDF by pushing the file to the client, and client to
choose "Save As" or "Open" the file directly.
Adobe reader is very slow if they run in browsers, and most of the
time, they hang the browser, so is there a way to push ?
regards,
Arnold
On Jul 17, 4:03 pm, Arnold Chen <arn...@design97.com> wrote:
> Thanks Ben,
>
> Besides, i've found thatwww.lawrence.comandwww.ljworld.com(which
> are famous sites that use django) use ahttp://media.their-domain-name.com
> to store the media files.
> All static files, images, css are from thehttp://media.their-domain-name.com
Content-Type: text/pdf
Content-Disposition: attachment; filename=yourfilename.pdf
That way most browsers will give you the option to open or to save-
as. To do that does require that they're sent dynamically, but as
said before it'd be a shame to use Django for that because of the
overhead you incur. Better off to just write some mod_python module
that will handle that sort of things.
IMO, anyway :)
from django.http import HttpResponse
def output_file(request, file, mimetype):
f = urllib.urlopen(file)
data = f.read()
f.close()
return HttpResponse(data, mimetype=mimetype)
It is better to serve from static environments but sometimes, you want
to check user rights for download and you can't avoid the django env.