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
  • 181,842
  • 47
  • 306
  • 310
marue
  • 5,588
  • 7
  • 37
  • 65

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
  • 181,842
  • 47
  • 306
  • 310
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,415
  • 12
  • 17