2

I have a bunch of files, that are being uploaded and tagged by users. When another user downloads one of those files, I want to create a filename like this:

creator_tag1_tag2_name.ext  

How can I do that? Does this have to happen on Django side or can it be done via jQuery?

miku
  • 172,072
  • 46
  • 300
  • 307
marue
  • 5,298
  • 7
  • 35
  • 64

2 Answers2

7

In your Django view corresponding to your download, you can set the content disposition header:

response['Content-Disposition'] = 'attachment; filename=somefilename.jpg'

A more detailed answer is given here:

Community
  • 1
  • 1
miku
  • 172,072
  • 46
  • 300
  • 307
2

You need to set returned HTTP header as something like the following:

response.headers['Content-disposition'] = 'attachment; filename=creator_tag1_tag2_name.ext'
ngduc
  • 1,377
  • 10
  • 16